W3A1 public_tests.py:initialize_parameters_test function's assertion expectation seems wrong

“AssertionError: Wrong shape for W1.” reported from

W1 shape expectation should be (4, 2)
as per your assignment’s documented markdown, ’ Expected output cell’, which displays W1 as a (4,2) matrix
public_tests.py:initialize_parameters_test is expecting:
expected_output[“W1”]shape of (5, 3)

  • W3A1
    public_tests.py:initialize_parameters_test function seems wrong…

so why is
expected number of hidden layer nodes getting set to 5?
n_h = 5

There are several separate test cases there and the point of having several is that they all use different dimension values, to make sure they catch errors if you “hard-code” any of the values.

These courses have been in operation for more than 5 years at this point, so it’s not a good strategy to assume that if your code fails the tests that means that the tests are broken. :laughing:

There are multiple tests. They use different conditions.

Some of the tests are built-into the notebook.

Some are in a separate utility file, which is called from within the notebook.

Why would 5 not be a legitimate value for n_h? In a two layer neural net, any number of neurons in the hidden layer between 1 and \infty is possible, right? Just because that doesn’t match what we do later is not relevant. The point of structuring the code as layers of functions is for “modularity”: we write each function to be general purpose, so we can reuse it in other cases. If you’re going to hard-code everything to match your particular data in a given case, then there’s no point in structuring things as layers of functions.

You are given the value as an input, so you just use it.

Thankyou Paulinpaloalto and TMosh for quick responses! … which cleared my confusion!