Extracting subgraph in tensorflow
<p>I have pretrained network and I'm trying to get just a part of it (subgraph) tf graph along with variables and saver object.</p>

<p>this is how I'm doing it:</p>

<pre><code>subgraph = tf.graph_util.extract_sub_graph(default_graph, list of nodes to preserve)
tf.reset_default_graph()
tf.import_graph_def(subgraph)
</code></pre>

<p>This however removes all variables (when I call reset_default_graph). Even If I explicitely add the operation nodes for variables (only the "variable" type operations) into the "list of nodes to preserve".</p>

<p>How can I preserve subgraph of larger graph while preserving values of variables?
Is it a matter of addition some new nodes to "preserve list"?</p>

<p>The relation between graph nodes and variables is still unclear to me and tutorial merely mentions that creation of variable creates some operations (nodes) in the graph.</p>