テンソルを名前で回復するのに問題がありますが、可能かどうかわかりません。Tensorflow:テンソルを名前で取得するには?
私は私のグラフを作成する機能を持っている:
def create_structure(tf, x, input_size,dropout):
with tf.variable_scope("scale_1") as scope:
W_S1_conv1 = deep_dive.weight_variable_scaling([7,7,3,64], name='W_S1_conv1')
b_S1_conv1 = deep_dive.bias_variable([64])
S1_conv1 = tf.nn.relu(deep_dive.conv2d(x_image, W_S1_conv1,strides=[1, 2, 2, 1], padding='SAME') + b_S1_conv1, name="Scale1_first_relu")
.
.
.
return S3_conv1,regularizer
は、私は、この関数の外変数S1_conv1にアクセスしたいです。私が試した:
with tf.variable_scope('scale_1') as scope_conv:
tf.get_variable_scope().reuse_variables()
ft=tf.get_variable('Scale1_first_relu')
しかし、それは私にエラーを与えている:
とValueError:アンダー共有:可変scale_1/Scale1_first_reluは、許可されていない、存在しません。 VarScopeでreuse = Noneを設定することを意味しましたか?
しかし、これは動作します:
with tf.variable_scope('scale_1') as scope_conv:
tf.get_variable_scope().reuse_variables()
ft=tf.get_variable('W_S1_conv1')
私は
return S3_conv1,regularizer, S1_conv1
でこの問題を回避することができますが、私はそれを行うにはしたくありません。
私の問題は、S1_conv1は実際には変数ではなく、単なるテンソルだと思います。私がしたいことをする方法はありますか?
参照のために、テンソルの代わりにOPを取得する必要がある場合:http://stackoverflow.com/questions/42685994/how-to-get-a-tensorflow-op-by-name –
@apfalz到着の仕方テンソル名は "example:0"ですか? – Bosen
あなたの質問があるかどうかわかりませんが、上記の例で 'e.name'を印刷すると、その名前は' example:0'です。 Tensorflowは指定した名前に ':0'を追加します。 – apfalz