I have completed the “Programming Assignment: Emojify” assignment.
Although all the tasks are “passed” I get a score of 0 for the following reason: “Exercise 5 - Cell # 22. Can’t compile the student’s code. Error: KeyError (‘funny’,)”.
Hey @ramitsurana , this output is misleading. We apologise for that.
In reality, your ex 3 implementation is incorrect. Since ex 3 has effects on ex 5, it says ex 5 is incorrect.
Kindly make sure your implementation of ex 3 is correct.
A common mistake in this function “sentence_to_avg” is when initialzing the avg variable.
You must use the shape of a word from the word_to_vec_map dictionary.
If you use one of the words from the ‘sentence’ variable, your code will likely throw a “KeyError(…)”, because there are several different dictionaries used. The dictionaries used by the exercise test case cells are very small, and most of the sentence words you might select by hard-coding are not found in those dictionaries.
So if you use (for example) “funny” or “the” or word[0] when finding the shape for the initial avg value, you’re probably going to get a good result on the exercise data set, but will fail on the test cases and the grader.
This is why the starter code computes the variable “any_word” for you to use in the initialization of “avg”. It is selected from the first word in the dictionary that is passed to the function.
Check everywhere in the notebook that you’re using word_to_vec_map or are calling the sentence_to_avg() function. Somewhere, you’re using a word from the sentence instead of using a word from the dictionary.
From comments earlier in this thread, a problem in the sentences_to_indices() function comes in the code you implement below this comment (for the ‘if’ statement within the second for-loop):