C5_W2_A1: Assertion error in Exercise 2

In Exercise 2 of the first Code Assignment, I’m facing the following assertion error:

AssertionError                            Traceback (most recent call last)
<ipython-input-82-321fc1e26750> in <module>
     33     print("\033[92mAll tests passed")
     34 
---> 35 complete_analogy_test(complete_analogy)

<ipython-input-82-321fc1e26750> in complete_analogy_test(target)
     29     assert(target('a', 'a_s', 'c', word_to_vec_map) == 'c_s')
     30     assert(target('a', 'synonym_of_a', 'c', word_to_vec_map) != 'c'), "Best word cannot be input query"
---> 31     assert(target('a', 'c', 'a', word_to_vec_map) == 'c')
     32 
     33     print("\033[92mAll tests passed")

AssertionError: 

which indicates that I’m not getting the correct output for my complete_analogy() function. However, when I check individually for:

complete_analogy('a', 'c', 'a', word_to_vec_map)

I do get ‘c’ as an output. In fact, I tried the line on a separate cell,

assert(complete_analogy('a', 'c', 'a', word_to_vec_map) == 'c')

and it executes without error, so I don’t know why I keep getting the assertion error within the evaluation function.

Do you know what could be happening here?

That is unusual.
Check your personal messages for instructions.

I agree, it’s a bit strange.
Thanks, I just replied to your message.

Dear @Charlie_DataScience,

Is the problem fixed?

1 Like

Hello. Not yet, but I just responded a couple of hours ago to TMosh’s personal message.

I’ll check it shortly. I’m at work at the moment.

Sure no problem, please take your time, it’s not urgent :slight_smile:

Problem solved, there was an error in the cosine_similarity() function that was only evident when incorporated in the complete_analogy() function.

We can close this loop. Thanks again for the support @TMosh

The issue has been resolved, there was an error in the cosine_similarity() function (which passed all its unit tests even with the error).

Tip: Do not modify any lines of code except where indicated in the notebook.

3 Likes