日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

tensorflow学习笔记:tf.control_dependencies,tf.GraphKeys.UPDATE_OPS,tf.get_collection

發(fā)布時(shí)間:2023/12/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tensorflow学习笔记:tf.control_dependencies,tf.GraphKeys.UPDATE_OPS,tf.get_collection 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
tf.control_dependencies(control_inputs): control_dependencies(control_inputs)

ARGS:

  • control_inputs:在運(yùn)行上下文中定義的操作之前必須執(zhí)行或計(jì)算的 Operation 列表或 Tensor 對(duì)象.也可以是不清除控件依賴項(xiàng).

返回:

指定上下文中構(gòu)建的所有操作的控制依賴關(guān)系的上下文管理器.

這個(gè)上下文就是with里邊的內(nèi)容

Use with the?with?keyword to specify that all operations constructed within the context should have control dependencies on?control_inputs. For example:

with g.control_dependencies([a, b, c]):# `d` and `e` will only run after `a`, `b`, and `c` have executed.d = ...e = ...

關(guān)于tf.GraphKeys.UPDATE_OPS,這是一個(gè)tensorflow的計(jì)算圖中內(nèi)置的一個(gè)集合,其中會(huì)保存一些需要在訓(xùn)練操作之前完成的操作,并配合tf.control_dependencies函數(shù)使用。

tf.get_collection():

get_collection(name,scope=None )

Args:

  • name: The key for the collection. For example, the?GraphKeys?class contains many standard names for collections.
  • scope: (Optional.) A string. If supplied, the resulting list is filtered to include only items whose?nameattribute matches?scope?using?re.match. Items without a?name?attribute are never returned if a scope is supplied. The choice of?re.match?means that a?scope?without special tokens filters by prefix.
# 在'My-TensorFlow-tutorials-master/02 CIFAR10/cifar10.py'代碼中variables = tf.get_collection(tf.GraphKeys.VARIABLES)for i in variables:print(i)>>> <tf.Variable 'conv1/weights:0' shape=(3, 3, 3, 96) dtype=float32_ref><tf.Variable 'conv1/biases:0' shape=(96,) dtype=float32_ref><tf.Variable 'conv2/weights:0' shape=(3, 3, 96, 64) dtype=float32_ref><tf.Variable 'conv2/biases:0' shape=(64,) dtype=float32_ref><tf.Variable 'local3/weights:0' shape=(16384, 384) dtype=float32_ref><tf.Variable 'local3/biases:0' shape=(384,) dtype=float32_ref><tf.Variable 'local4/weights:0' shape=(384, 192) dtype=float32_ref><tf.Variable 'local4/biases:0' shape=(192,) dtype=float32_ref><tf.Variable 'softmax_linear/softmax_linear:0' shape=(192, 10) dtype=float32_ref><tf.Variable 'softmax_linear/biases:0' shape=(10,) dtype=float32_ref>

?

總結(jié)

以上是生活随笔為你收集整理的tensorflow学习笔记:tf.control_dependencies,tf.GraphKeys.UPDATE_OPS,tf.get_collection的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。