Expected output
The size of the input layer is: n_x = 5
The size of the hidden layer is: n_h = 4
The size of the output layer is: n_y = 2
All tests passed!
My code outputs these values (included below), but I get this error with different expected values:
The size of the input layer is: n_x = 5
The size of the hidden layer is: n_h = 4
The size of the output layer is: n_y = 2
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-23-a625d2d64083> in <module>
5 print("The size of the output layer is: n_y = " + str(n_y))
6
----> 7 layer_sizes_test(layer_sizes)
~/work/release/W3A1/public_tests.py in layer_sizes_test(target)
23
24 assert type(output) == tuple, "Output must be a tuple"
---> 25 assert output == expected_output, f"Wrong result. Expected {expected_output} got {output}"
26
27 print("\033[92mAll tests passed!")
AssertionError: Wrong result. Expected (7, 4, 5) got (5, 4, 2)
There is more than one test case here. It looks like you are “hard-coding” the answers, instead of deriving them from the shapes of the inputs, as David suggests. “Hard-coding” is always a mistake, unless they specifically tell you to do that. We are trying to write general code here which works with any inputs.
Thanks for the quick replies, actually I’m not hard-coding them (except n_h, as stated in the text). I believe I can’t send more details about my solution, but what confused me is the text below the test results saying the expected outputs should be 5, 4, 2 and that seems what I’ve got with my answer. I’ll reset the notebook and try again.
It sounds like the bug was not literal “hard-coding”, but that you must have been referencing a global variable instead of the actual parameter(s) passed to the function.