C5W2A2: Cell #14. Can't compile the student's code. Error: ValueError('shapes (5,2) and (5,) not aligned: 2 (dim 1) != 5 (dim 0)',)

I have completed the assignment 2 of the week 2 of Course 5 with all the test cases passed. Yet it is showing the same error each time I submit my assignment.

It appears that your code has an error that was not caught by any of the unit tests.


are you solve this proplem?

I don’t have any records of how @reetik07 solved the issue.

Sorry for not updating about it.
This error occurred because of wrong initialization of the average word vector due to which it was showing an error of the shapes not being aligned. The issue is now resolved.

I’m facing the exact same issue. Can you please share exactly how you solved this issue?

Thank you.

Personally, my error was to initialize like this :
avg = 0
Rather than : (It solved my error)
any_word = list(word_to_vec_map.keys())[0]
avg = np.zeros((word_to_vec_map[any_word].shape[0],))

i.e : avg = np.zeros((50,))

1 Like

Had the same issue, your solution solved it. Thanks!