C5W2: Emojify: the model gives zero accuracy

In the Emojify assignment, I have implemented the first model (the model() function). The test shows that I get 0 accuracy. Any idea what I might be doing wrong without me having to post the actual code?

Hi @Meir ,

In order to diagnose your problem, we need more information. Do your have a submission summary? any error messages?

1 Like

The code does not pass the assertion in the cell following the one containing the graded function model():

assert np.allclose(pred.transpose(), Y), "Model must give a perfect accuracy"

Hi @Meir ,

The assertion is triggered because the two arrays ‘pred’ and ‘Y’ are not elementwise equal within a tolerance level. ‘pred’ is one of the outputs from calling model(). So you need to check if your code follows those formulas in model().

2 Likes

That was exactly my question. To the best of my understanding, my code should be doing the right thing. I checked all the dimensionalities, so everything seems to make sense. Would it be possible to show you my code without disclosing it to everyone else?

1 Like

yes, sure, post it to me by DM

1 Like

I’m having the same issue, is there a general follow-up hint you can provide?

Hi @psteele ,

Your problem may not necessary the same as Meir, could you give us some information, such as error messages etc?

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-80-fb9aec72420c> in <module>
     29     print("\033[92mAll tests passed!")
     30 
---> 31 model_test(model)

<ipython-input-80-fb9aec72420c> in model_test(target)
     24 
     25     assert W.shape == (2, 2), "W must be of shape 2 x 2"
---> 26     assert np.allclose(pred.transpose(), Y), "Model must give a perfect accuracy"
     27     assert np.allclose(b[0], -1 * b[1]), "b should be symmetric in this example"
     28 

AssertionError: Model must give a perfect accuracy
1 Like

I checked and the label, Y, is this: [0 0 0 0 0 0 1 1 1 1 1 1]
whereas the pred is this: [[0. 0. 0. 0. 0. 0. 0. 1. 1. 0. 0. 1.]]

I know its getting 2 of the 12 wrong but its also returning a list of a single list of floats.

I checked my model code and am stumped on why the accuracy is off.

Hi @psteele ,

Check the section of code enclosed by ‘START CODE HERE’ and ‘END CODE HERE’.

A couple of suggestions to check:

  1. parameters passing to functions - when calculating the variable ‘avg’ and ‘z’,
  2. calculation of cost - is you code following the formula?

Were you able to fix it? I got the same error

still haven’t fixed it.

just figured it out from here: Emoji_v3a model() must give perfect accuracy

that dot product symbol is horrible - needs to be clearer - wasted so much time because it was so subtle.

Yeah, right?! I only was able to see it after the tutors answer…