title: Eval Variable in Tensorflow
body: <p>From the <a href="https://stackoverflow.com/a/38990824/1691873">this post</a>, I known that <code>Tensor.eval()</code> is equalent to <code>tf.get_default_session().run(t)</code>, but When I eval a tensor, I met errors. The code below emit errors if line marked by 1 is omitted, Why? Then I tried to call <code>W.initializer</code>'s <code>eval()</code> method to replace <code>run()</code>,  but the <code>W.initializer</code> has no <code>eval()</code> method and <code>tf.constant</code>(as a operation) do has one, Why?</p>
  
  <pre><code>def test_eval():
      W = tf.constant(10)
      with tf.Session():
          print(W.eval())         # 10
  
  
  def test_eval_Variable():
      W = tf.Variable(10)
      with tf.Session() as sess:
          print(sess.run(W.initializer))  # None &lt;--- 1.
          print(W.eval())                 # 10
  
  
  def test_eval_Variable_all():
      W = tf.Variable(10)
      with tf.Session():
          print(W.initializer.eval())  # error: object has no attribute 'eval'
          print(W.eval()) 
  </code></pre>