title: Difference between graph.get_tensor_by_name and tf.global_variable
body: <p>I can get a tensor by graph.get_tensor_by_name, however I cannot find it in tf.global_variable.
  In my case, I defined some tf.Tensor as follows:</p>
  
  <pre><code>output_y = Dense(units=y.shape[1],activation='softmax',kernel_regularizer=regularizers.l2(),bias_regularizer=regularizers.l2(),activity_regularizer=regularizers.l2(),name='output_y_'+str(index))(pretrain_output)
  y_tf = tf.placeholder(tf.float32, shape=(None, y.shape[1]),name='y_tf_'+str(index))
  loss_tensor = tf.nn.softmax_cross_entropy_with_logits(logits=output_y, labels=y_tf, name='loss_tensor_' + str(index))
  </code></pre>
  
  <p>I can export the tensor shape and name as follows:</p>
  
  <pre><code>&gt;&gt;output_y
  &lt;tf.Tensor 'train_variable/output_y_0/Softmax:0' shape=(?, 4) dtype=float32&gt;
  &gt;&gt;y_tf
  &lt;tf.Tensor 'train_variable/y_tf_0:0' shape=(?, 4) dtype=float32&gt;
  &gt;&gt;loss_tensor
  &lt;tf.Tensor 'train_variable/loss_tensor_0/Reshape_2:0' shape=(?,) dtype=float32&gt;
  </code></pre>
  
  <p>Also, I can use tf.get_default_graph.get_tensor_by_name to retrieve the tensor:</p>
  
  <pre><code>&gt;&gt;tf.get_default_graph().get_tensor_by_name('train_variable/output_y_0/Softmax:0')
  &lt;tf.Tensor 'train_variable/output_y_0/Softmax:0' shape=(?, 4) dtype=float32&gt;
  &gt;&gt;tf.get_default_graph().get_tensor_by_name('train_variable/y_tf_0:0')
  &lt;tf.Tensor 'train_variable/y_tf_0:0' shape=(?, 4) dtype=float32&gt;
  &gt;&gt;tf.get_default_graph().get_tensor_by_name('train_variable/loss_tensor_0/Reshape_2:0')
  &lt;tf.Tensor 'train_variable/loss_tensor_0/Reshape_2:0' shape=(?,) dtype=float32&gt;
  </code></pre>
  
  <p>However, these variable names cannot be found in tf.global_variables(). It seems that tf.global_variables() only contains the parameter variables like kernel/bias. Now I have to remember the tensor name in order to retrieve the object output (output_y in my case). Can someone show me how to retrieve a tensor, for example search it in a list with all tensor?</p>