Tensorflow Variables and Ops vs. Python Equivalents
<p>I'm new to Tensorflow.</p>

<ul>
<li>Is it necessary to use tensorflow's function, such as using <code>tf.constant()</code> to replace <code>int32</code>, <code>float32</code> or else?</li>
<li>Also during computation, using <code>tf.mul()</code> instead of normal Python multiplication <code>*</code>?</li>
<li>Also the print function <code>tf.Print()</code> instead of <code>print()</code>?</li>
</ul>

<p>As noted <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/api_docs/python/framework.md#class-tftensor-tensor" rel="nofollow">here</a>, </p>

<blockquote>
  <p>A Tensor is a symbolic handle to one of the outputs of an Operation. It does not hold the values of that operation's output, but instead provides a means of computing those values in a TensorFlow Session</p>
</blockquote>

<p>So tensor variables aren't like python variables. Rather they specify the relationship between operations in the <a href="https://www.tensorflow.org/versions/r0.11/resources/faq.html#building-a-tensorflow-graph" rel="nofollow">computational graph</a>. The python variables that you use to describe the graph are for the programmer's convenience, but it might be easier to think about the python variables and the tensor variables as being in parallel namespaces. This example may help:</p>

<pre><code>with tf.Session() as sess:
  a = tf.constant([1, 2, 3])
  b = tf.Variable([])
  b = 2 * a
  sess.run(tf.initialize_all_variables())
  print(b) # Tensor("mul:0", shape=(3,), dtype=int32)
  print(b.eval()) # [2, 4, 6]
  b = tf.Print(b, [b])  # [2, 4, 6] (at the command line)
</code></pre>

<p>From this you can see:</p>

<ul>
<li><code>print(b)</code> returns information about the operation that 'b' refers to as well as the variable shape and data type, but not the value.</li>
<li><code>b.eval()</code> (or <code>sess.run(b)</code>) returns the value of <code>b</code> as a numpy array which can be printed by a python <code>print()</code></li>
<li><code>tf.Print()</code> allows you to see the value of <code>b</code> during graph execution. </li>
</ul>

<p>Note that the syntax of <code>tf.Print()</code> might seem a little strange to a newbie. As described in the documentation <a href="https://www.tensorflow.org/versions/r0.11/api_docs/python/control_flow_ops.html#Print" rel="nofollow">here</a>, <code>tf.Print()</code> is an identity operation that only has the side effect of printing to the command line. The first parameter is just passed through. The second parameter is the list of tensors that are printed and can be different than the first parameter. Also note that in order for <code>tf.Print()</code> to do something, a variable used in a subsequent call to <code>sess.run()</code> needs to be dependent on the tensor output by <code>tf.Print()</code>, otherwise this portion of the graph will not be executed.</p>

<p>Finally with respect to math ops such as <code>tf.mul()</code> vs <code>*</code> many of the normal python ops are overloaded with the equivalent tensorflow ops, as described <a href="http://stackoverflow.com/a/37901852/5587428">here</a>.</p>

python tensorflow