question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot feed value of shape for Tensor when predicting model with image

See original GitHub issue

I get this error when trying to perform prediction with a new image on trained model:

Traceback (most recent call last):
  File "/home/andrey/.venvs/ludwig-learn/bin/ludwig", line 11, in <module>
    sys.exit(main())
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/ludwig/cli.py", line 86, in main
    CLI()
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/ludwig/cli.py", line 64, in __init__
    getattr(self, args.command)()
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/ludwig/cli.py", line 73, in predict
    predict.cli(sys.argv[2:])
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/ludwig/predict.py", line 379, in cli
    full_predict(**vars(args))
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/ludwig/predict.py", line 104, in full_predict
    debug
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/ludwig/predict.py", line 173, in predict
    gpu_fraction=gpu_fraction
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/ludwig/models/model.py", line 1182, in predict
    only_predictions=only_predictions
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/ludwig/models/model.py", line 756, in batch_evaluation
    is_training=is_training
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run
    run_metadata_ptr)
  File "/home/andrey/.venvs/ludwig-learn/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1128, in _run
    str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1,) for Tensor 'image_path/image_path:0', which has shape '(?, 100, 100, 3)'

The model definition I use:

input_features:
    -
        name: image_path
        type: image
        encoder: stacked_cnn
        in_memory: false
        height: 100
        width: 100

output_features:
    -
        name: tags
        type: set`

Example of testing csv-file:

image_path,tags
testdata/cat.101.jpg

I’ve tried output features with category and set types but eventually get that error.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
abogoyavlenskycommented, Mar 17, 2019

@w4nderlust Ok, thanks, here the link to my dataset sample and commands I use ludwig-prediction-example.zip

1reaction
w4nderlustcommented, Feb 17, 2019

Got it, it may be the case that I’m not correctly applying the preprocessing to image features in prediction. Will look into it. @ydudin3 can you also try to check this out?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TensorFlow ValueError: Cannot feed value of shape (64, 64, 3 ...
You have to feed it with a value of (1,64,64,3) = a batch of 1 image. Just reshape your image value to a...
Read more >
ValueError: Cannot feed value of shape (3,) for Tensor 'X:0 ...
I get the following error "ValueError: Cannot feed value of shape (2500, 1, 3) for Tensor 'X:0', which has shape '(1, 3)'". I...
Read more >
Problem in tensorflow, Cannot feed value of shape (140, 29 ...
As the value error is already suggesting you, the input you are giving to the placeholder, and the shape of that placeholder don't...
Read more >
ValueError: Cannot feed value of shape (1, 3, 299 ... - GitHub
I am clueless why it is showing this value error. The error looks like a clash between tensorflow and theano background. Idk why...
Read more >
Cannot feed value of shape (50, 41) for Tensor u'Placeholder ...
data set has 42 attributes and program is given below and please have a look on attached image for error. import csv. import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found