title: Tensorflow: How to modify the value in tensor
body: <p>Since I need to write some preprocesses for the data before using Tensorflow to train models, some modifications on the <code>tensor</code> is needed. However, I have no idea about how to modify the values in <code>tensor</code> like the way using <code>numpy</code>. </p>
  
  <p>The best way of doing so is that it is able to modify <code>tensor</code> directly. Yet, it seems not possible in the current version of Tensorflow. An alternative way is changing <code>tensor</code> to <code>ndarray</code> for the process, and then use <code>tf.convert_to_tensor</code> to change back. </p>
  
  <p>The key is how to change <code>tensor</code> to <code>ndarray</code>.<br>
  1) <code>tf.contrib.util.make_ndarray(tensor)</code>:
  <a href="https://www.tensorflow.org/versions/r0.8/api_docs/python/contrib.util.html#make_ndarray" rel="noreferrer">https://www.tensorflow.org/versions/r0.8/api_docs/python/contrib.util.html#make_ndarray</a><br>
  It seems the easiest way as per the document, yet I cannot find this function in the current version of the Tensorflow. Second, the input of it is <code>TensorProto</code> rather than <code>tensor</code>.<br>
  2) Use <code>a.eval()</code> to copy <code>a</code> to another <code>ndarray</code><br>
  Yet, it works only at using <code>tf.InteractiveSession()</code> in notebook. </p>
  
  <p>A simple case with codes shows below. The purpose of this code is making that the <code>tfc</code> has the same output as <code>npc</code> after the process.   </p>
  
  <p><strong>HINT</strong><br>
  You should treat that <code>tfc</code> and <code>npc</code> are independent to each other. This meets the situation that at first the retrieved training data is in <code>tensor</code> format with <a href="https://www.tensorflow.org/versions/r0.8/api_docs/python/io_ops.html#placeholder" rel="noreferrer"><code>tf.placeholder()</code></a>. </p>
  
  <hr>
  
  <p><strong>Source code</strong></p>
  
  <pre><code>import numpy as np
  import tensorflow as tf
  tf.InteractiveSession()
  
  tfc = tf.constant([[1.,2.],[3.,4.]])
  npc = np.array([[1.,2.],[3.,4.]])
  row = np.array([[.1,.2]])
  print('tfc:\n', tfc.eval())
  print('npc:\n', npc)
  for i in range(2):
      for j in range(2):
          npc[i,j] += row[0,j]
  
  print('modified tfc:\n', tfc.eval())
  print('modified npc:\n', npc)
  </code></pre>
  
  <hr>
  
  <p><strong>Output:</strong></p>
  
  <p>tfc:<br>
   [[ 1.  2.]<br>
   [ 3.  4.]]<br>
  npc:<br>
   [[ 1.  2.]<br>
   [ 3.  4.]]<br>
  modified tfc:<br>
   [[ 1.  2.]<br>
   [ 3.  4.]]<br>
  modified npc:<br>
   [[ 1.1  2.2]<br>
   [ 3.1  4.2]]  </p>