Tensorflow: ¿Cómo obtener un tensor por nombre?
Tengo problemas para recuperar un tensor por nombre, ni siquiera sé si es posible.
Tengo una función que crea mi gráfico:
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
Quiero acceder a la variable S1_conv1 fuera de esta función. Lo intenté:
with tf.variable_scope('scale_1') as scope_conv:
tf.get_variable_scope().reuse_variables()
ft=tf.get_variable('Scale1_first_relu')
Pero eso me está dando un error:
ValueError: Compartición insuficiente: la variable scale_1 / Scale1_first_relu no existe, no se permite. ¿Quería configurar reuse = None en VarScope?
Pero esto funciona:
with tf.variable_scope('scale_1') as scope_conv:
tf.get_variable_scope().reuse_variables()
ft=tf.get_variable('W_S1_conv1')
Puedo evitar esto con
return S3_conv1,regularizer, S1_conv1
pero no quiero hacer eso
Creo que mi problema es que S1_conv1 no es realmente una variable, es solo un tensor. ¿Hay alguna manera de hacer lo que quiero?