我的問題是有關這個Tensorflow: How to get a tensor by name?TensorFlow:如何命名爲操作tf.get_variable
我可以給名稱運營。但實際上他們的名字不同。 例如:
In [11]: with tf.variable_scope('test_scope') as scope:
...: a = tf.get_variable('a',[1])
...: b = tf.maximum(1,2, name='b')
...: print a.name
...: print b.name
...:
...:
...:
test_scope/a:0
test_scope_1/b:0
In [12]: with tf.variable_scope('test_scope') as scope:
...: scope.reuse_variables()
...: a = tf.get_variable('a',[1])
...: b = tf.maximum(1,2, name='b')
...: print a.name
...: print b.name
...:
...:
...:
test_scope/a:0
test_scope_2/b:0
tf.get_variable
具有完全相同的名稱創建變量我問。操作爲範圍添加前綴。
我想命名我的操作,以便我可以得到它。在我的情況下,我想在我的範圍內獲得b
和tf.get_variable('b')
。
我該怎麼辦?我不能這樣做tf.Variable
由於這個問題https://github.com/tensorflow/tensorflow/issues/1325 可能是我需要設置變量範圍,或操作,或以某種方式使用tf.get_variable
增加參數?
謝謝!我不確定我完全理解初始化程序是什麼。它是否適用於可訓練和不可訓練的變量? – ckorzhik
不客氣!初始化器只是一個將變量設置爲初始值的操作。是的,它應該適用於可訓練和不可訓練的變量。對於可訓練變量,需要從tf.get_variable()中設置參數'trainable = True',以將該變量添加到可訓練變量的集合中。 – rvinas