W4_A1_Ex-2_AssertionError_Initialize Parameters_deep

Hi guys,

I am trying to implement the second function (initialize_parameters_deep). I am stuck in the for loop where I have to assign weights and biases. The weights. are fine but I initialize the biases to zeros of size layer_dims[l] and 1 as suggested in the instructions but it throws an assertion error. Any suggestion is highly appreciated. I am not sure if I am allowed to paste my code in here.

It’s against the rules to share source code for the solutions publicly, but it’s fine to show the output you get even if that includes an exception trace, which might reveal a little bit of the code. The assertions there are pretty straightforward: they just check the shapes. If your shapes are wrong, try printing them out. One common mistake is to use 1 (one) instead of l (lower case ell) as the index. Those are pretty hard to distinguish in the font that they use. :scream_cat:

Hy, when i try

Initialize the output volume Z with zeros. (≈1 line)

Z = np.zeros((m, n_H, n_W, n_C))

I got the error
‘float’ object cannot be interpreted as an integer

My model for the Week 4 assignment works fine in Colab but fails when run from the grader, giving the following error : "Failed test case: your model could not be used for inference. "

Ok, well, which one of those variables is not an integer? The first rule of debugging is “believe the error message” and that one is about as clear as they get. Try printing their types. Or go back and look at how they are set.

print(f"type(m) = {type(m)}")

and so forth …

I don’t think it’s a good idea to work on a course notebook on Colab and then upload it back onto the course website. We have seen instances in which Colab rewrites some of the invisible “metadata” in the JSON files that are the notebooks in such a way that it no longer works with the Coursera graders.

My suggestion would be that you start with a clean copy of the notebook on the course website and then “copy/paste” over just your code from the “YOUR CODE HERE” sections from the uploaded Colab version and see if that helps. The point being that doing that would get you back to the Coursera version of the “metadata” in the notebook.

There is a topic on the DLS FAQ Thread about how to get a fresh copy.

Please try that and let us know what happens.