C5W2A2:Cell #13. Can't compile the student's code.Error: ValueError('operands could not be broadcast together with shapes (5,) (5,2) ',)


When tested it in jupyer it said ‘All tests passed’ but when submit it,the error occured as shows.
I have tried it again and again but the error still occur.
6UHHC29AFR_AE}GVMJM5%H8

As shows,It seems to be an error since I have added try…except to locate where the error occurs,and I have resized b to (n_y,1) in the except code but error still happens

Why couldn’t I see my post?

Hi ra224,

If you send me your notebook in a private message, I can have a look at what’s going on.

Hi dear Mentor,
Thank you for reply!
Of course,I have downloaded for an ipynb file and sent to you.

Hi ra224,

There is a problem with the shape of the avg vector returned by your implementation of sentence_to_avg.

Note that the relevant instruction in UNQ_C1 reads as follows:

" # Initialize the average word vector, should have the same shape as your word vectors."

Note also that len only returns the size along the first axis, whereas you want the full shape of the word vector.

Can you think of a way to resolve this?

2 Likes

Hi dear Mentor,
Thank you very much!
This homework has passed with your remind~!

I got same error, because in sentence_to_avg, I have initialized the avg as " avg = 0 ",
which is able to pass the test, but will got error when submitting.
After I followed the comments : " Initialize the average word vector, should have the same shape as your word vectors. ".
I use the np.zeros, and the word to vec with the “any_word” to initial the avg
then, I got the pass