Gizmo
Gizmo

Reputation: 941

How to create a multidimensional Tensor?

I am referring to the MNIST tutorial on the TensorFlow website. There is a tensor for holding the 28 by 28 pixel MNIST images. The shape looks as following:

x = tf.placeholder(tf.float32, shape=[None, 784])

As you can see they have flattened the matrix and use all pixels as a one-dimensional vector of 784 values.

How would one set up a tensor with a proper matrix of 28 by 28 pixel? I would like to conserve the information about the 2D structure of the image.

Upvotes: 0

Views: 1525

Answers (1)

Charmander35
Charmander35

Reputation: 115

The way to create the placeholder tensor is the same:

x = tf.placeholder(tf.float32, shape=[None, 28, 28])

But of course it must now be fed with appropriately sized images instead of the aforementioned flattened images (vectors).

Edit: Note of course you still have "None" in the first dimension as you don't want to fully specify how many images will be fed in at once.

Upvotes: 1

Related Questions