Hi! you need to use it with np.zeros
Hi @keks1208,
How did you initialise avg?
It should be :
np.zeros((word_to_vec_map[any_word].shape))
i tried a different approach for define avg
avg = np.zeros_like(word_to_vec_map[words[0]])
why is it wrong?
i print the shape and it was (50,)
but didn’t pass assert test starting with “love”
Hi @newton,
‘love’ is not in the word_vec_map. Your code should only add to the ‘avg’ if the word can be found in word_vec_map; otherwise, your code is wrong. How does your ‘if’ statement work?
The problem is that the words in the sentence may not appear in the dictionary.
So you can’t assume that word[0] will be found.
And the function is tested with several different dictionaries.
Hi, I have same issues mentioned above. The tests are successful, but I got the error : Can’t compile the student’s code. Error: KeyError(‘never’,)
Pls help me out
If you get KeyErrors, it typically means that your code is referencing the words in the sentence rather than the words in the dictionary.