iamaaditya / VQA_Demo

Visual Question Answering Demo on pretrained model
http://iamaaditya.github.io/2016/04/visual_question_answering_demo_notebook
MIT License
242 stars 134 forks source link

ValueError: Error when checking : expected lstm_4_input to have shape (None, 30, 300) #14

Closed michael20at closed 6 years ago

michael20at commented 6 years ago

Hi,

i get

ValueError: Error when checking : expected lstm_4_input to have shape (None, 30, 300) but got array with shape (1, 7, 300)

on y_output = model_vqa.predict([question_features, image_features])

Any idea why?

Thanks for your help!

fG Mike

Update: I found out that the problem is "len(tokens)"! The question was seven tokens long.

If I change "len(tokens" to "30" it works, but don't think that should be right?

iamaaditya commented 6 years ago

I just checked the code, and it works for me without any changes on TF 1.2.0, Keras 2.0.8 and Spacy (both 1.9.0 and the old 0.101). What versions are you using? If the question length is less than 30, they are padded by zero. Check the dimensions of the tensor tokens in here https://github.com/iamaaditya/VQA_Demo/blob/master/demo.py#L76 . On line 78 you can see that code only updates those places of question_tensor for which the word exist. If you had 10 words in the question, then question_tensor[0,0,:] to question_tensor[0,10,:] will be updated and 11 --> 30 will remain zero.

michael20at commented 6 years ago

It works when i use demo.py after some corrections, error remains only in the notebook.

I think the problem is that I use Python 3 and you used 2, because I had to change some things in demo.py to get it to run (range instead of xrange, no unicode, str parentheses, etc.), after that demo.py worked!

iamaaditya commented 6 years ago

Yes, I have not updated the Notebook in a while. If you have a working version of the notebook I would be willing to accept a pull request.

Thanks and Regards Adi

On Fri, Oct 13, 2017 at 3:46 PM, michael20at notifications@github.com wrote:

It works when i use demo.py after some corrections, error remains only in the notebook.

I think the problem is that I use Python 3 and you used 2, because I had to change some things in demo.py to get it to run (range instead of xrange, no unicode, str parentheses, etc.), after that demo.py worked!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/iamaaditya/VQA_Demo/issues/14#issuecomment-336549986, or mute the thread https://github.com/notifications/unsubscribe-auth/AB008iDl4tD-0XGDB6_Oh4Unix3XB9k7ks5sr738gaJpZM4P3qiD .