Course 5 week 2 project 2

OK, here again working on the emoji project. Second half of it is gold I think but the first function is what is tripping me up. I am just unsure of where the variable ‘any_word’ is used. Anyone have any suggestions where to use it. In initializing the “avg” variable? From the directions that is where i am thinking. I currently have it as avg = np.zeros((50,))

Hard-coding a shape is usually a bad idea, unless the instructions specifically mention to do that.

any_word is used in initializing the avg word vector, as follows:

  • Use any_word to look up its word vector in the word_to_vec_map.
  • Then you use its .shape attribute.
  • That shape is used in np.zeros()

You can pack all of that into one line of code.

1 Like

Awesome. Thank you so much. I am still getting an error, but it is successfully starting to run now. Every thing is good to go and passed. Sadly i submitted it for a grade and i got a 0/100 on it. The only error message the autograder gives is:

Cell #22. Can't compile the student's code. Error: KeyError('funny',)

I put in print statements to try to see it, but it looks like its part of the hidden test that fails, so i can’t see why that “funny”, vector is failing. Still it is passing the notebook autograder, but failing the overall autograder. Even when i put the word funny in the sentence of the notebook unit tests, it passes in the notebook.

@TMosh I had this issue with another test yesterday that i had been stuck on. The notebook reports that everything is correct, but the hidden tests fail on the autograder. @paulinpaloalto helped me through that one and filed a bug report for me. I can file a bug report if i know how since i think i am one of the first people through these tests on your new platform.

Hi, Dennis. But be sure to remember the point of that previous exercise you are referring to: it ended up being a bug in your code, it’s just that the unit tests in the notebook didn’t catch it. So the question is to understand what the nature of the bug is here. I actually haven’t gotten to this exercise yet, so I don’t know what the code is doing. But the point is that the grader is throwing a runtime error when it tries to run your code. It looks like the nature of the error is that it is doing a dictionary lookup with the key ‘funny’ and that lookup fails, meaning the dictionary does not contain that key. So where are there dictionary lookups in your code? How might one of them go off the rails in this way? Add some instrumentation to the logic that creates and populates the dictionary in question. Do you see the key ‘funny’ getting added? You can explicitly check for that.

BTW I’ve seen other students reporting this same symptom, so it might be worth searching discourse for ‘funny’ …

1 Like

@paulinpaloalto Thank you so much for the advice. Making me remember the process of troubleshooting correctly. And I do apologize for blurting out bug. I meant it from a standpoint of the students view. There are some idiosyncratic “features” to be aware of. Mainly don’t assume the code is correct if the notebook reports it. You can rabbithole down some different directions.