tensorflow - How to fetch a Variable from the graph in the session? -
i want inspect filters of convolutional layers. trying fetch variables during last step of session.
here simplified version of model:
graph = tf.graph() graph.as_default(): # placeholders ... # variables. conv1_w = tf.variable(..., name='conv1_w') ... optimizer = ... accuracy = ... tf.session(graph=graph) session: ... acc, c1 = session.run([accuracy, conv1_w], feed_dict=feed_test) i following exception
fetch argument <tensorflow.python.ops.variables.variable object @ 0x137890710> cannot interpreted tensor. (tensor tensor("conv1_w:0", shape=(5, 5, 1, 16), dtype=float32_ref) not element of graph.) however, if apply op, can fetch resulting tensor without error:
c1_op = tf.mul(conv1_w,1.0) optimizer = ... accuracy = ... does tensorflow not allow fetch variables?
it might confusing variable name , "name" parameter both conv1_w
aside seems isn't being used @ in computation graph. meaning there's no data being pushed through or not being used.
quick simple example:
import tensorflow tf sess = tf.interactivesession() conv1 = tf.variable(1) sess.run(tf.initialize_all_variables()) sess.run(conv1) result 1
as side note: it's better use tf.get_variable() instead of tf.variable()
Comments
Post a Comment