Skip to Content
精通機器學習
book

精通機器學習

by Aurélien Géron
April 2020
Intermediate to advanced
816 pages
18h 32m
Chinese
GoTop Information, Inc.
Content preview from 精通機器學習
672
|
第十九章:大規模訓練與部署 TensorFlow 模型
如果你想要將操作放到非預設的裝置
可使用
tf.device()
>>> with
tf.device("/cpu:0"):
...
c = tf.Variable(42.0)
...
>>>
c.device
'/job:localhost/replica:0/task:0/device:CPU:0'
CPU
一定會被視為單一裝置
/cpu:0
),
即使你的電腦有多個
CPU
核心
如果
CPU
有多執行緒
kernel
被放到
CPU
的任何操作都可以在多個核心
之間平行運行
如果你明確地將一個操作或變數放到不存在或沒有
kernel
的裝置
你將會看到例外
是有時你可能比較想要退回去使用
CPU
例如
如果你的程式可以在純
CPU
電腦運行
也可以在
GPU
電腦運行
你可能想要讓
TensorFlow
在純
CPU
電腦忽略
tf.device("/
gpu:*")
為此
你可以在匯入
TensorFlow
之後呼叫
tf.config.set_soft_device_
placement(True)
當一個置放請求失敗時
TensorFlow
會退回去使用它的預設置放規則
也就是當
GPU 0
存在而且有
GPU kernel
預設使用
GPU 0
否則使用
CPU 0)。
那麼
TensorFlow
究竟是如何在多台裝置上執行這些操作的
在多台裝置上平行執行
12
章介紹過
使用
TF Functions
的其中一項好處就是平行執行
我們來更深入地討論
這一點
TensorFlow ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

下一代空间计算:AR与VR创新理论与实践

下一代空间计算:AR与VR创新理论与实践

Erin Pangilinan, Steve Lukas, Vasanth Mohan
C语言核心技术(原书第2版)

C语言核心技术(原书第2版)

Peter Prinz, Tony Crawford

Publisher Resources

ISBN: 9789865024345