W3_A1_Wrong shape for W2

This is a very strange error in Excercise3

def initialize_parameters(n_x, n_h, n_y):
AssertionError: Wrong shape for W2.

But my result is exactly the same as Expected output
W2 = [[-0.01057952 -0.00909008 0.00551454 0.02292208]]

even Excercise4 can pass without error. But Ex3 error always exist. Anybody knows why?

Notice that you filed this under DLS Course 3, but it’s really Course 1. I moved it for you by using the little “edit pencil” on the title.

Well, notice that there are two completely separate test cases there. One where you can see the results in the notebook and another one that is in public_tests.py. It looks like your W2 is correct for the visible test, but the other test must be failing. One thing to check is to make sure you did not hard-code any of the dimensions. E.g. do you always use 1 for n_y? That will work for the visible test, but fail for the other test. You can examine the other test by clicking “File → Open” and then opening the file public_tests.py or the file testCases_v2.py if you want to see the parameters for the visible test.

Thank you for the hint, I kinda find the problem. I don’t hard anything except some ‘1’ value is fixed.

in the test script:
def initialize_parameters_test_case():
n_x, n_h, n_y = 2, 4, 1

it fixes n_h to 4

but when verify
initialize_parameters_test(initialize_paramet
n_x, n_h, n_y = 3,5,2
it test by n_h=5

the initilizatoin and the verify is not consistent.
Is that correct?

Hi @yschangd_CHANG ,

The public test uses n_x, n_h, n_y = 3,5,2, a ifferent set of data, to test your code. If your code is correct, it will produce the expected output.
One way to debug is put a print statement in your code to print out the shape of W2. That should give some indication as to where the problem might be.

hi Kic, I print W2 shape out and its result is (1,4)
it looks like the same as expected result of W2 = [[-0.01057952 -0.00909008 0.00551454 0.02292208]]

i already submit the assignment and pass, however, this is the only mistake. is it possible you help check what goes wrong? i am wondering why my accuracy is only 0.58, is this where the bug is.

We can’t directly see your notebooks. Please check your DMs for a message from me about how to proceed.