Assertion Error: Model must give a perfect accuracy

Hi, I am not able to run this test successfully.
I am getting accuracy 0.9166666666666666
This is in the second question (def model_test)
Below is the error message:

AssertionError Traceback (most recent call last)
26 print(“\033[92mAll tests passed!”)
—> 28 model_test(model)

in model_test(target)
22 assert W.shape == (2, 2), “W must be of shape 2 x 2”
—> 23 assert np.allclose(pred.transpose(), Y), “Model must give a perfect accuracy”
24 assert np.allclose(b[0], -1 * b[1]), “b should be symmetric in this example”

AssertionError: Model must give a perfect accuracy

Which week of the course? Which assignment?

Week2, Assignment- Emojify

Also, out of 5 exercises in the assignment, all tests passed for the last 3 (exercise 3,4,5) however the evaluator is still giving me 0/100

Hi @SheikhFarhan ,

Looking at the traceback posted here. The reason for the assertion being triggered with the error message ‘Model must give a perfect accuracy’ is due to the two arrays, pred and Y, are not elementwise equal within a tolerance level.
The problem is most likely to be within model(). A couple of suggestions to check your code enclosed by the ‘START CODE HERE’ and ‘END CODE HERE’:

  1. forward propagation of avg
  2. calculation of cost
    making sure the correct parameters are passed to the calling functions.


I’m still having trouble with this section and have been working on it for several weeks. I have the same issue where my prediction doesn’t match Y. My accuracy drops to 0.75 on the 100th epoch. Would it be possible to take this offline to get some help?

Hi @psteele

Post that section of code in a DM to me, and I will have a look for you.

@Kic it was solved in Emoji_v3a model() must give perfect accuracy

that ‘dot’ symbol is very subtle and doesn’t look like a mathematical dot operator - that was the issue for me.

Great to hear you have got it working.

I will let the team know about the dot operator issue. Thanks for your comment.

Hello. I have the same problem:
Epoch: 0 — cost = 13.020271195168233
Accuracy: 0.8333333333333334
Epoch: 100 — cost = 2.3632182794792467
Accuracy: 0.75
but I don’t know how to solve it

I found an error. I had the wrong order of multiplication: it was, W,), and above,avg)

Glad to know that. ~~~~~