nouhadziri / THRED

The implementation of the paper "Augmenting Neural Response Generation with Context-Aware Topical Attention"
https://arxiv.org/abs/1811.01063
MIT License
111 stars 25 forks source link

Test Issue- ValueError: Cannot feed value of shape(x,1) for Tensor 'Placeholder:0' which has shape '(?,)' #5

Closed Pritishsingla closed 5 years ago

Pritishsingla commented 5 years ago

I am trying to use the vanilla version of the model for a dialogue generation task i.e given a statement by speaker#1, generate a statement by speaker#2 I have successfully trained the model but while testing I run into the following error. I believe the format for the test file is only the source statements without the target statements(with no tabs).

> Traceback (most recent call last):
  File "/home/ydz853/data/THRED/main.py", line 51, in <module>
    tf.app.run()
  File "/home/ydz853/.conda/envs/env_1/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "/home/ydz853/data/THRED/main.py", line 47, in main
    model.test()
  File "/home/ydz853/data/THRED/models/vanilla/vanilla_wrapper.py", line 545, in test
    infer_sess.run(infer_model.iterator.initializer, feed_dict=feed_dict)
  File "/home/ydz853/.conda/envs/env_1/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 889, in run
    run_metadata_ptr)
  File "/home/ydz853/.conda/envs/env_1/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1096, in _run
    % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape(100,1) for Tensor 'Placeholder:0' which has shape '(?,)'
ehsk commented 5 years ago

The test file format is same as the training file (i.e., tab-separated utterances including the ground truth response). Seems the error is attributed to the incorrect format. Please let us know if changing the format did not solve the problem.

Pritishsingla commented 5 years ago

Thanks for the quick reply.

I am still getting the same error. The format for the test file being used is - s1\ts2 where s2 is the ground truth statement. Please note that the model is able to generate some sample responses while training. I am using the vanilla_small model.

The error is:

Traceback (most recent call last): File "main.py", line 51, in <module> tf.app.run() File "/home/ydz853/.conda/envs/env1/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "main.py", line 47, in main model.test() File "/home/ydz853/data/THRED/models/vanilla/vanilla_wrapper.py", line 545, in test infer_sess.run(infer_model.iterator.initializer, feed_dict=feed_dict) File "/home/ydz853/.conda/envs/env1/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 889, in run run_metadata_ptr) File "/home/ydz853/.conda/envs/env1/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1096, in _run % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (1000, 2) for Tensor 'Placeholder:0', which has shape '(?,)'

ehsk commented 5 years ago

The error is fixed. Thanks for raising the issue.

Pritishsingla commented 5 years ago

Thanks. The code works fine now.