Week 1 Assignment 1 Exercise 5 Assert Issue

When applying the conv_backward I get everything right, except for the shape of db…

dA_mean = 1.4524377775388075
dW_mean = 1.7269914583139097
db_mean = 7.839232564616846

AssertionError Traceback (most recent call last)
in
21 assert dA.shape == (10, 4, 4, 3), f"Wrong shape for dA {dA.shape} != (10, 4, 4, 3)"
22 assert dW.shape == (2, 2, 3, 8), f"Wrong shape for dW {dW.shape} != (2, 2, 3, 8)"
—> 23 assert db.shape == (1, 1, 1, 8), f"Wrong shape for db {db.shape} != (1, 1, 1, 8)"
24 assert np.isclose(np.mean(dA), 1.4524377), “Wrong values for dA”
25 assert np.isclose(np.mean(dW), 1.7269914), “Wrong values for dW”

AssertionError: Wrong shape for db (10, 4, 4, 8) != (1, 1, 1, 8)

How is that possible that I get the right final answer with the wrong db shape? db has the same shape as dZ.

But the point is that is wrong. So how did that happen? I can’t explain how the mean could still be correct, but the shape is clearly wrong. Where do you initialize db? What is the shape you are using? Where do you update db? What is the shape of the value on the RHS of that assignment statement?

Here is my code with db highlighted.

{moderator edit - solution code removed}

The shape of db is the same as the shape of b, right? Well, what is the shape of b? Clue: m is not involved.

1 Like

Yeah, I was just going to edit the answer as I was highlighting it. Got it. Thanks