【发布时间】:2018-08-23 10:01:19
【问题描述】:
我在图表的一部分中创建了一个变量范围,稍后在图表的另一部分中,我想将 OP 添加到现有范围中。这相当于这个提炼的例子:
import tensorflow as tf
with tf.variable_scope('myscope'):
tf.Variable(1.0, name='var1')
with tf.variable_scope('myscope', reuse=True):
tf.Variable(2.0, name='var2')
print([n.name for n in tf.get_default_graph().as_graph_def().node])
产量:
['myscope/var1/initial_value',
'myscope/var1',
'myscope/var1/Assign',
'myscope/var1/read',
'myscope_1/var2/initial_value',
'myscope_1/var2',
'myscope_1/var2/Assign',
'myscope_1/var2/read']
我想要的结果是:
['myscope/var1/initial_value',
'myscope/var1',
'myscope/var1/Assign',
'myscope/var1/read',
'myscope/var2/initial_value',
'myscope/var2',
'myscope/var2/Assign',
'myscope/var2/read']
我看到这个问题似乎没有直接解决该问题的答案:TensorFlow, how to reuse a variable scope name
【问题讨论】:
标签: python tensorflow machine-learning deep-learning tensor