iamaaditya/VQA_Demo

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

michael20at opened this issue · 3 comments

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?

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.

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!