I'm trying to understand placeholders in tensorflow. Specifically what shape=[None,
means in the example below.
X = tf.placeholder(tf.float32, shape=[None, 128, 128, 3], name="X")
This answer describes it as:
You can think of a placeholder in TensorFlow as an operation specifying the shape and type of data that will be fed into the graph.placeholder X defines that an unspecified number of rows of shape (128, 128, 3) of type float32 will be fed into the graph. a Placeholder does not hold state and merely defines the type and shape of the data to flow into the graph.
When it says "unspecified number of ROWS" does it really mean unspecified number of tensors of shape 128*128*3? Like you are creating a placeholder for input images for input images to a CNN?
The first dimension represents the number of samples (images in your case). The reason why you do not want to hardcode a specific number there is to keep things flexible and allow for any number of samples. By putting None
as the first dimension of the tensor you enable that. Consider the following 3 very common actions:
All of these will work with a different number of samples in general. However, you do not have to worry because the None
got you covered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With