How to fetch a Variable from the graph in the session?
<p>I want to inspect the filters of convolutional layers. To do this I am trying to fetch the variables during the last step of the session.</p>

<p>Here is a simplified version of my model:</p>

<pre><code>graph = tf.Graph()
with graph.as_default():

    # Placeholders
    ...

    # Variables.
    conv1_w = tf.Variable(..., name='conv1_w')
    ...

    optimizer = ...
    accuracy = ...

with tf.Session(graph=graph) as session:
    ...
    acc, c1 = session.run([accuracy, conv1_w], feed_dict=feed_test)
</code></pre>

<p>I get the following exception            </p>

<pre><code>Fetch argument &lt;tensorflow.python.ops.variables.Variable object at 0x137890710&gt; cannot be interpreted as a Tensor. (Tensor Tensor("conv1_w:0", shape=(5, 5, 1, 16), dtype=float32_ref) is not an element of this graph.)
</code></pre>

<p>However, if I apply an op, I can fetch the resulting tensor without the error:</p>

<pre><code>    c1_op = tf.mul(conv1_w,1.0)
    optimizer = ...
    accuracy = ...
</code></pre>

<p>Does Tensorflow not allow to fetch Variables?</p>