C5W2 emojify assignment

Hi, I tried submitting this assignment several times and keep getting the autograder error “Cell #13. Can’t compile the student’s code. Error: KeyError(‘never’,)”. I have checked other threads reporting the same error, most of the problems seem to be based around this code:

for w in words:
        # Check that word exists in word_to_vec_map
        if w in list(word_to_vec_map.keys()):
            avg += word_to_vec_map[w]

Somehow words not in word_to_vec_map seem to be getting through the if condition and then returning a key error, but I cannot figure out why. None of the solutions presented in other threads seem to apply in this case. Please help.

Try removing the list from the keys.

@Kyle_Paterson Please click my name and message your notebook as an attachment.

Thanks, but removing list() doesn’t seem to make any difference.

You need to post in the page of your specialization, there people who are familiar with this assignment might help you.

I have moved the thread to the Deep Learning Specialization Course 5 forum area.

“if w in word_to_vec_map:” ought to be sufficient.

Or perhaps there’s an error in how you’re setting the “words” variable.

I’ve checked his notebook in coursera environment. It runs fine. I’ve created an issue for this.

Credit: @TMosh

@Kyle_Paterson: Please check the code below this comment:
# Average the word vectors of the words from the i'th training example

The way you are computing the average vector is not the same as in the function sentence_to_avg.

Thanks, it appears that this was the problem. Correcting the average calculation allowed me to submit without errors.