0

I tried to test some learning networks after I completed training with a tensorflow.

But my test image is [512 512 1] data of channel 1 in 512 horizontal and 512 vertical pixels.

I changed the image data to a numpy array.

The tensor network should be [? 512 512 1] It looks like this.

How do I convert a numpy array to a tensor? ([512 512 1] -> [? 512 512 1])

3
  • What is the leading ? dimension for? Commented Nov 9, 2018 at 9:32
  • A message says ... ValueError: Cannot feed value of shape (512, 512, 1) for Tensor 'images:0', which has shape '(?, 512, 512, 1)' Commented Nov 9, 2018 at 9:38
  • Yes, but what is the ? dimension? Batch size? Commented Nov 9, 2018 at 9:46

1 Answer 1

4

You just have to append one dimension

arr = your_image # [512, 512, 1]
new_arr = np.expand_dims(arr, 0)

tensor = tf.convert_to_tensor(new_arr)

Now you can use feed dict or something else.

Sign up to request clarification or add additional context in comments.

1 Comment

thsnks you very very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.