Thanks for your response. I searched the forum but I seem to have defined the condition correctly both in sentence_to_avg and sentences_to_indices functions
“if w in word_to_vec_map:” in sentence_to_avg function
“for w in sentence_words:” in sentences_to_indices function
I seem to have initialized the avg variable also correctly as below
avg = np.zeros(word_to_vec_map[any_word].shape)
Kindly let me know where is the issue. Which is cell #21 in the notebook.
Check the code block in the second ‘For’ loop follows the implementation instructions, especially the ‘if’ statement is checking ‘w’ against word_to_index.
There is no if statement in the 2nd For loop in “sentences_to_indices” function . Pls see my code in 2nd for loop below.
So kindly clarify which if block are you referring to?
Also please let me know which is cell #21 that is causing the error (as per the auto grader). This will help in debugging.
for w in sentence_words:
# Set the (i,j)th entry of X_indices to the index of the correct word.
X_indices[i, j] = word_to_index[w]
# Increment j to j + 1
j = j + 1
The ‘If’ statement is needed to check whether the ‘w’ exists in the word_to_index.
As explained in the comment statement:
word_to_index – a dictionary containing the each word mapped to its index.
I have no knowledge of how the auto grader works, so I can’t help with the error cell reported.