Planar data classification with one model nn_model fails

As work through Week 3 programming assignment, I have gone through the entire notebook where the test cases of all the helper functions working fine but the nn_model is failing.

I have submitted my assignment all the test cases are passed except nn_model.

My accuracy of model which has to be at 90 is at 52 because of the learnt model. Can someone help me to fix this bug.

You mean your current model accuracy is at 52%?

Also did you check that the tests before that specific point (or cells) is passing? If one or more of the tests are not passing, then some errors or issues may have been propagated from that cell.

Can you rerun the cells from the top again step by step and ensure the tests pass.

@jeosol I have done that multiple times rerun each cell from top to bottom.

I have submitted the Assignment and everything passed except nn_model. The parameter values are not matching.

I think you can get 52% training accuracy if you reverse the train and test data.

@paulinpaloalto nn_model is failing test cases, Want to know why it’s failing?

Whereas all my helper functions passed the test cases

@varunm

Did you make the changes and the matrix operations are not consistent and then no broadcasting errors you mentioned in your first post. Or by nn_model failing, you mean the errors are still there. Or all the tests are now passing?

The forward propagation step, the operation involving w and X must be consistent in terms of the initial number row and columns. After the operation, the resulting dimension is consistent with those of b.

Did you review the forward propagation equations before Exercise 5.

@jeosol forward propagation, backward propagation, compute cost and update parameters methods are working perfectly fine, But surprisingly nn_model is not working. What could be the reason?

When I say it’s not working I mean it’s test cases are failed.

That means there are bugs in your nn_model function. Just because the lower level functions are correct, they can still malfunction if you call them incorrectly, e.g. with the wrong parameters.

Common mistakes are referencing global variables instead of the actual parameters being passed in for the training and test data or “hard-coding” parameters like the learning rate and number of iterations when you call the lower level functions from nn_model.

@paulinpaloalto
I understand your point but as nn_model is only using lower level functions, I couldn’t find mistake in the Code. Could you please have a look?

{moderator edit - solution code removed}

You have misspelled the name of the variable to which you assign the return value of update_parameters. If that is your idea of careful proofreading, you are in for some rough sailing here. Just sayin’ :nerd_face:

The result of that bug is that the parameter values never change as you run the loop, which accounts for both the bad training accuracy results and the fact that it fails the test cases.

@paulinpaloalto
I am screwing my head to understand if I am missing some logic. Thanks it is fixed now.
Corrected my typo. :slightly_smiling_face:

1 Like