Week 4 - Exercise 9 - L_model_backward

1 Tests passed
2 Tests failed

AssertionError Traceback (most recent call last)
in
9 print("db2 = " + str(grads[‘db2’]))
10
—> 11 L_model_backward_test(L_model_backward)

~/work/release/W4A1/public_tests.py in L_model_backward_test(target)
442 ]
443
→ 444 multiple_test(test_cases, target)
445
446 def update_parameters_test(target):

~/work/release/W4A1/test_utils.py in multiple_test(test_cases, target)
140 print(’\033[92m’, success," Tests passed")
141 print(’\033[91m’, len(test_cases) - success, " Tests failed")
→ 142 raise AssertionError(“Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))
143

AssertionError: Not all tests were passed for L_model_backward. Check your equations and avoid using global variables inside the function.

Hi @Haifa,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.

I shall take a look.

When you reply back, kindly tag me in the post so that I’m notified.

Thanks,
Mubsi

Hi, I am having a similar error and would appreciate some assistance. I am getting the right array shapes and values for dA1,dW2,db2 so I guess I am doing ok the linear_activation_backward for de L layer. But then for the remaining layers (with ‘relu’) I am getting wrong array shapes and values. I checked the output sizes in the inside functions and seems ok. I also spend some time analyzing how I am calling the activation inside the for but can’t find the error.Could it be that I am linking different layers? I will keep looking it but if someone can give me a clue as to where this error could be, I would appreciate it! Thank you

image

I put a bunch of print statements in my L_model_backward code to print the layer numbers and the various gradients. Here’s what I get when I run that test cell:

dAL = [[-0.5590876   1.77465392]]
L = 2
dA2.shape = (1, 2)
dW2.shape = (1, 3)
l = 0
dW1.shape = (3, 4)
db1.shape = (3, 1)
dA0 = [[ 0.          0.52257901]
 [ 0.         -0.3269206 ]
 [ 0.         -0.32070404]
 [ 0.         -0.74079187]]
dA1 = [[ 0.12913162 -0.44014127]
 [-0.14175655  0.48317296]
 [ 0.01663708 -0.05670698]]
dW1 = [[0.41010002 0.07807203 0.13798444 0.10502167]
 [0.         0.         0.         0.        ]
 [0.05283652 0.01005865 0.01777766 0.0135308 ]]
dW2 = [[-0.39202432 -0.13325855 -0.04601089]]
db1 = [[-0.22007063]
 [ 0.        ]
 [-0.02835349]]
db2 = [[0.15187861]]
dAL = [[-0.5590876   1.77465392]]
L = 2
dA2.shape = (1, 2)
dW2.shape = (1, 3)
l = 0
dW1.shape = (3, 4)
db1.shape = (3, 1)
dAL = [[-0.5590876   1.77465392]]
L = 2
dA2.shape = (1, 2)
dW2.shape = (1, 3)
l = 0
dW1.shape = (3, 4)
db1.shape = (3, 1)
dAL = [[-0.5590876   1.77465392]]
L = 2
dA2.shape = (1, 2)
dW2.shape = (1, 3)
l = 0
dW1.shape = (3, 4)
db1.shape = (3, 1)
 All tests passed.

As you say, it looks like your dW2 and dA1 values are the right shape, but everything else is the wrong shape. That means it’s the logic in the “for” loop that is wrong, so that’s the place to look.

thanks @paulinpaloalto, I was already printing the dAx and dWx values and sizes but printing also the “L” and “l” definitively help me on solving this error. Fixed!