title: Layer names for pretrained inception v3 model (tensorflow)
body: <p>The task is to get per-layer output of a <a href="https://www.tensorflow.org/versions/master/tutorials/image_recognition/index.html" rel="nofollow noreferrer">pretrained cnn inceptionv3</a> model.
  For example I feed an image to this network, and I want to get not only its output, but output of each layer(layer-wise).</p>
  
  <p>In order to do that, I have to know names of each layer output. It's quite easy to do for last and pre-last layer:</p>
  
  <pre><code>sess.graph.get_tensor_by_name('pool_3:0')
  sess.graph.get_tensor_by_name('softmax:0')
  </code></pre>
  
  <p>(names pool_3:0 and softmax:0 are listed in sources related to the model)</p>
  
  <p>But what if I want to get output of not only last and pre-last layer, but also pre-pre-last, pre-pre-pre-last, etc, output of any layer of this model?</p>
  
  <p>Then I have to know layer names. A similar question <a href="https://stackoverflow.com/questions/34175174/extract-features-using-pre-trained-tensorflow-cnn">has been asked</a>
   on stackoverflow, but there are only names for pre-last and last layers, which are also available in comments in the sources('pool_3:0', 'softmax:0')</p>
  
  <p>The obvious way to get names is to draw a graph of the model. But it's not the case <a href="https://stackoverflow.com/questions/35635131/unable-to-visualize-inception-v3-model-in-tensorboard-with-tensorflow-0-7-1">because graph-drawing tool simply crashes</a>.
  Also there is an <a href="https://github.com/tensorflow/tensorflow/issues/1287" rel="nofollow noreferrer">issue</a> related to this.</p>
  
  <p>I also tried:</p>
  
  <ol>
  <li>To print all graph node names and construct graph using information only from node names. But node names are quite cryptic. Also connections between nodes are not so obvious, because of <a href="http://arxiv.org/pdf/1512.00567v3.pdf" rel="nofollow noreferrer">inception v3 architecture</a> So without knowing the connections between nodes, this approach is like to break the code of enigma :)</li>
  <li>Then I tried to draw a graph of this model using own-written tool(get all inputs of given node(say, 'pool_3:0'), then get all inputs of each of inputs of 'pool_3:0', etc. This approach works for simple models. But when I tried to use it for inceptionv3 implementation from THE image recognition tutorial, I've got 16 GB of my RAM used, then 10 GB of swap, then I simply stopped looking under the hood. Maybe there are some cycles in graph(but how could it be if the network is feed-forward?)</li>
  </ol>
  
  <p>So, maybe somebody who's participated in this pre-trained model implementation &amp; 'shipping' is reading stackoverflow.</p>
  
  <p>Or maybe somebody has already got layer-wise names for this model.
  Please share it with me and ml community. Thanks in advance!</p>