Week 3 Exercise 4 grader error

I do not know how to link to the classroom item but it is week 3 exercise 4 initializing parameters. I really believe I have the correct answer but yet it is saying I have the wrong shape. My output looks exactly like the expected output. I have also tried resetting the notebook but the steps doesn’t work as my answers are still in the notebook with those steps. My results show in picture. Is it still possible I’m wrong even though my output looks exactly the same?

Yea, this is a strange one. I don’t see anything wrong with the output, and this test looks like it hasn’t been changed in 3 years.

Can you private message me with your code for initialize_parameters()? It could help with the debugging.

Actually, on second inspection, it looks like the test case actually tests on different parameters than the printed expected output.

I think what you’re likely getting wrong is that you should be using n_h, n_x, and n_y with the code you write inside initialize_parameters(). Do not use constant numbers like 1, 2, 3, 4, etc.

I agree with @hackyon.

The formatting of the test results is a little misleading.
A) First the notebook displays your results for the built-in test.
B) Then it calls the unittest function. Your code has an error so it throws an assert.
C) Then the notebook shows the expected results for A).

Right. What that result means is what hackyon says: you must have hard-coded the sizes in a way that happens to match the visible test in the notebook. But then the other test (which you can read by opening the file public_tests.py) specifically uses different parameters to catch the type of “hard-coding” error you must have made.

BTW these courses have been in operation for more than 5 years at this point, so it’s a bad idea to assume that if a test fails that the test must be broken. It would have been fixed by now. If the test fails, then you need to figure out what the test failure is telling you about your code.

Got it guys, thanks… I interpreted the “Refer to the neural network figure above if needed” as look at the model and define the shape from that. I didn’t imagine hard coding parameters would make the difference. Thank you.

That’s an important lesson to keep in mind: the point of structuring solutions as layers of functions is for modularity and reusability. You want the functions to be “general”, meaning they work in as many cases as possible. Hard-coding is always a mistake unless they specifically tell you to do it that way. You’ll see a few instances of that, but not many.