在tensorflow中,如何确定变量属于哪个集合?

时间:2018-12-10 12:27:24

标签: python tensorflow

我是张量流启动器。

我知道我可以使用get_collection函数从变量所属的集合中获取变量。 而且我知道变量可以嵌入到多个集合中。

如下

import tensorflow as tf
# define variable
var1 = tf.constant(0.0,shape=[1,32,32,3])

# Add var to 'my_collections'
tf.add_to_collection('my_collections' ,value=phase_train)

print(tf.get_collection(tf.GraphKeys.LOCAL_VARIABLES))
# >>> [<tf.Variable 'Variable:0' shape=(1, 32, 32, 3) dtype=float32_ref>]
print(tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES))
# >>> [<tf.Variable 'Variable:0' shape=(1, 32, 32, 3) dtype=float32_ref>]

所以,这是我的问题。 那么如何确定包含特定变量的集合?

0 个答案:

没有答案
相关问题