Learner For-life
Learner For-life

Reputation: 53

TensorFlow MNIST example feeding own images

I am trying to learn TensorFlow, so I was trying to understand their example with smaller dimensions. Suppose I have image1, image2, image3 three 28x28 matrices which hold grayscale values (0..255). image1 is the training image, image2 is the validation image, and image3 is the test image. I was trying to understand how I can feed my own images into the MNIST example they have here.

I am particularly interested in replacing the following line with my own imageset:

X, Y, testX, testY = mnist.load_data(one_hot=True)

Your help is much appreciated.

Upvotes: 0

Views: 663

Answers (2)

童学智
童学智

Reputation: 41

mnist.load_data(one_hot=True) is nothing but some preprossesing of the data. If you have some images in hand, you can just make them an ndarray and feed into the graph. For examples if you have a node named images, you can feed the images using feed_dict = {images: some_image}.

Upvotes: 0

Olivier Moindrot
Olivier Moindrot

Reputation: 28198

Suppose your image is a numpy array, of shape [1, 28, 28, 1].

You can just feed this numpy array to the node X or textX. Even though X is not a placeholder, you can provide its value to TensorFlow.

X_value = ...  # numpy array
# ... same for Y_value, testX_value, testY_value

feed_dict = {X: X_value, Y: Y_value, testX: testX_value, testY: testY_value}
sess.run(train_op, feed_dict=feed_dict)

Upvotes: 1

Related Questions