I\'m a newbie to TensorFlow. I\'m confused about the difference between tf.placeholder and tf.Variable. In my view, tf.placeholder is
Adding to other's answers, they also explain it very well in this MNIST tutorial on Tensoflow website:
We describe these interacting operations by manipulating symbolic variables. Let's create one:
x = tf.placeholder(tf.float32, [None, 784]),
xisn't a specific value. It's a placeholder, a value that we'll input when we ask TensorFlow to run a computation. We want to be able to input any number of MNIST images, each flattened into a 784-dimensional vector. We represent this as a 2-D tensor of floating-point numbers, with a shape [None, 784]. (Here None means that a dimension can be of any length.)We also need the weights and biases for our model. We could imagine treating these like additional inputs, but TensorFlow has an even better way to handle it:
Variable. AVariableis a modifiable tensor that lives in TensorFlow's graph of interacting operations. It can be used and even modified by the computation. For machine learning applications, one generally has the model parameters beVariables.
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))We create these
Variables by givingtf.Variablethe initial value of theVariable: in this case, we initialize bothWandbas tensors full of zeros. Since we are going to learnWandb, it doesn't matter very much what they initially are.