这里是tensorflow中的tf.GraphKeys的文档,例如TRAINABLE_VARIABLES
:将由优化器训练的Variable对象的子集.
我知道tf.get_collection()
,哪个可以找到你想要的张量.
使用时tensorflow.contrib.layers.batch_norm()
,参数updates_collections
默认值为GraphKeys.UPDATE_OPS
.
我们如何理解这些集合及其差异.
此外,我们可以在ops.py中找到更多.
请参阅代码段:
import tensorflow as tf
x = tf.Variable(1)
op = tf.assign(x, x + 1)
with tf.Session() as sess:
tf.global_variables_initializer().run()
print(sess.run([x, op]))
Run Code Online (Sandbox Code Playgroud)
有两种可能的结果:
它们取决于评估的顺序,对于第一种情况,x
在之前进行评估op
,对于第二种情况,x
在之后进行评估op
.
我已多次运行代码,但结果总是如此x=2 and op=2
.所以我想这tensorflow
可以保证x
在之后进行评估op
.这样对吗?如何tensorflow
保证依赖?
对于上面的情况,结果是确定的.但在以下情况中,结果并不确定.
import tensorflow as tf
x = tf.Variable(1)
op = tf.assign(x, x + 1)
x = x + 0 # add this line
with tf.Session() …
Run Code Online (Sandbox Code Playgroud)