The automatic grader of lab assignment of C1_W3 NLP course

I have a problem with NLP C1 Week3 grader. I fail the get_country and get_accuracy although I pass all tests within. I am stuck there. I have finished the 4 weeks and cannot move on because of this faulty grader? Can you please advise!
Assignment: Vector Space Models | Coursera

1 Like

You have probably made the most common mistake on this assignment, which is referencing the global variable word_embeddings from the body of your get_country function. What if the grader passes a different dictionary?

It is not a bug in the grader: your code is incorrect, but it happens to work in the notebook because that is the variable that is passed in those test cases. That mistake also causes the get_accuracy function to fail the grader, because it calls get_country.

3 Likes

I changed it from word_embedding to embedding only and it worked! Thanks a lot for your support and prompt reply!

Glad that my hint was enough for you to fix the problem! That’s an important point to remember: referencing global variables from the body of a function is always a mistake at least in these courses. There can be other ways to structure code where it is ok, but here they are very careful about modularity of functions.

4 Likes

Thank you so much

1 Like