title: Check if node is an operation or a tensor in Tensorflow Graph
body: <p>Using <code>names = [n.name for n in graph.as_graph_def().node]</code> I can get all the node names in the graph. </p>
  
  <p>For instance, say this prints:</p>
  
  <pre><code>['model/classifier/dense/kernel/Initializer/random_uniform/shape',
  'model/classifier/dense/kernel/Initializer/random_uniform/min',
  'model/classifier/dense/kernel/Initializer/random_uniform/max',
  'model/classifier/dense/kernel/Initializer/random_uniform/RandomUniform',
  'model/classifier/dense/kernel/Initializer/random_uniform/sub',
  'model/classifier/dense/kernel/Initializer/random_uniform/mul',
  'model/classifier/dense/kernel/Initializer/random_uniform',
  'model/classifier/dense/kernel',
  'model/classifier/dense/kernel/Assign',
  'model/classifier/dense/kernel/read',
  'model/classifier/dense/bias/Initializer/zeros/shape_as_tensor',
  'model/classifier/dense/bias/Initializer/zeros/Const',
  'model/classifier/dense/bias/Initializer/zeros',
  'model/classifier/dense/bias',
  'model/classifier/dense/bias/Assign',
  'model/classifier/dense/bias/read',
  'model/classifier/dense/MatMul',
  'model/classifier/dense/BiasAdd'] 
  </code></pre>
  
  <p>How can I select only the operations or only the tensors?</p>
  
  <p>I'm aware of the following workarounds, which will work in specific situations but are not general enough and would not scale to a large graph:</p>
  
  <ul>
  <li><p>string manipulations from the above names</p>
  
  <ul>
  <li><p>for instance to get <code>model/classifier/dense/kernel</code>: </p>
  
  <pre><code>tensor = [graph.get_tensor_by_name(n + ":0") 
      for n in names if 'classifier' in n and
      'kernel' in name and 
      not n.split('kernel')[-1]
  ][0]
  </code></pre></li>
  <li>As you can imagine this may be very error prone and is very tensor specific</li>
  </ul></li>
  <li><p><code>try/except</code> I could get the tensors which are outputs of these operation with:</p>
  
  <pre><code>tensors = []
  for name in names:
      try:
          tensors.append(graph.get_tensor_by_name(name + ":0"))
      except KeyError:
          pass
  </code></pre>
  
  <ul>
  <li>But again this is but a workaround and does not solve the selection problem: what if I just want the <code>kernel</code> Tensor?</li>
  </ul></li>
  </ul>