Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does x = tf.placeholder(tf.float32, [None, 784]) means?

Tags:

I know basic use for tf.placeholder:

x = tf.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)

with tf.Session() as sess:
   print(sess.run(y))  # ERROR: will fail because x was not fed.

   rand_array = np.random.rand(1024, 1024)
   print(sess.run(y, feed_dict={x: rand_array}))  # Will succeed.

I know the second parameter is about shape. However I don't know what is that mean when the first one is None in the shape. ex:[None,784].

like image 656
Rachel Jennifer Avatar asked Sep 03 '16 09:09

Rachel Jennifer


People also ask

What does TF placeholder do?

A placeholder is a variable in Tensorflow to which data will be assigned sometime later on. It enables us to create processes or operations without the requirement for data. Data is fed into the placeholder as the session starts, and the session is run.

Why do we use placeholder in TensorFlow?

A placeholder is simply a variable that we will assign data to at a later date. It allows us to create our operations and build our computation graph, without needing the data. In TensorFlow terminology, we then feed data into the graph through these placeholders.

What is Feed_dict in TensorFlow?

The feed_dict argument is used in TensorFlow to feed values to these placeholders, to avoid getting an error that prompts you to feed a value for placeholders in the TensorFlow.


1 Answers

From the tutorial: Deep MNIST for Experts

Here we assign it a shape of [None, 784], where 784 is the dimensionality of a single flattened 28 by 28 pixel MNIST image, and None indicates that the first dimension, corresponding to the batch size, can be of any size.

like image 63
nessuno Avatar answered Oct 11 '22 08:10

nessuno