从collection中取op

来源:互联网 发布:免费洗车的软件 编辑:程序博客网 时间:2024/05/17 09:10
#coding=utf-8import tensorflow as tfwith tf.name_scope("hello") as name_scope:    arr1 = tf.get_variable("arr1", shape=[2,10],dtype=tf.float32)    a = tf.Variable(0,name='a')arr2 = tf.get_variable('arr2', shape=[1,2], dtype=tf.float32)collection = tf.get_collection(tf.GraphKeys().GLOBAL_VARIABLES,'a')#选取集合中名称开头为'a'的opprint(*collection)


结果:

<tf.Variable 'arr1:0' shape=(2, 10) dtype=float32_ref> <tf.Variable 'arr2:0' shape=(1, 2) dtype=float32_ref>


原创粉丝点击