C2W1 Gradient check / Exercise_4

I’m stuck at Exercise 4 forever. Does someone know what has gone wrong?

TypeError Traceback (most recent call last)
----> 1 X, Y, parameters = gradient_check_n_test_case()
3 cost, cache = forward_propagation_n(X, Y, parameters)
4 gradients = backward_propagation_n(X, Y, cache)
5 difference = gradient_check_n(parameters, gradients, X, Y, 1e-7, True)

TypeError: gradient_check_n_test_case() missing 4 required positional arguments: ‘parameters’, ‘gradients’, ‘X’, and ‘Y’

Hi, Mike.

Welcome to the DLS series. One minor point is that you filed this under “General Discussion”. This Discourse forum supports I think about 5 different specializations at this point with more being added all the time, so you’re a lot more likely to have your question noticed by the right people if you file it under the relevant category. I went ahead and moved it for you by using the “pencil” edit icon on the title.

I’ve never seen this error before. I looked at that function, which is defined in the file testCases.py that gets imported by the first cell in the notebook. The function gradient_check_n_test_case legitimately does not take any arguments, so the only way I can explain that error message is that one of the following must have happened:

  1. You modified the function definition by editing the file testCases.py. If so, that’s not a good idea. You can get back the original by deleting the file and then doing the “Get Fresh Copy” procedure documented on the FAQ Thread.

  2. You accidentally modified the function definition for gradient_check_n in the notebook itself (which actually does have those positional parameters) so that you changed the name of the function to gradient_check_n_test_case instead. If that’s the case, please change it back and see what happens.

If neither of the above explain things, then please let us know.

For some reason testCases.py wasn’t imported at all. I changed the whole notebook drastically and it didn’t reset even after following your guide.

Could you maybe send a new file for the programming assignment to start from there? I’m pretty sure I got this after this.

Thanks so much sir.

The topic on the FAQ Thread explains how you can get fresh copies of the notebook or any of the files associated with it. Please read the topic all the way to the end.

If you claim you followed the procedure and things did not get replaced, it means you did not read the instructions carefully enough. It will only replace missing files: that means you need to rename your notebook out of the way and delete any of the “dot py” files.