C2 - Week1 - Assignment 2 [Regularzaitons] - Exercise 2

Hi, In C2 - Week1 - Assignment 2 [Regularzaitons] - Exercise 2 - for backward propagation with regularization, 1 Tests failed. I have updated the regularization code for dW3, dW2, dW1.

Requesting your help. Thanks.

dW1 =
[[-0.10206168 0.14712822 -0.16007111]
[-0.18297295 0.26376681 -0.28697042]]
dW2 =
[[0.72241565 0.72521935]
[0. 0. ]
[0. 0. ]]
dW3 =
[[-1.68070929 0. 0. ]]
1 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
in
5 print (“dW2 = \n”+ str(grads[“dW2”]))
6 print (“dW3 = \n”+ str(grads[“dW3”]))
----> 7 backward_propagation_with_regularization_test(backward_propagation_with_regularization)

~/work/release/W1A2/public_tests.py in backward_propagation_with_regularization_test(target)
100 ]
101
→ 102 multiple_test(test_cases, target)
103
104 def forward_propagation_with_dropout_test(target):

/opt/conda/lib/python3.7/site-packages/dlai_tools/testing_utils.py in multiple_test(test_cases, target)
162 print(‘\033[91m’, len(test_cases) - success, " Tests failed")
163 raise AssertionError(
→ 164 “Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))

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

Here are the correct answers for that test cell:

dW1 = 
[[-0.25604646  0.12298827 -0.28297129]
 [-0.17706303  0.34536094 -0.4410571 ]]
dW2 = 
[[ 0.79276486  0.85133918]
 [-0.0957219  -0.01720463]
 [-0.13100772 -0.03750433]]
dW3 = 
[[-1.77691347 -0.11832879 -0.09397446]]
 All tests passed.

Comparing those, notice that your values have lots of zeros for dW2 and dW3. How could that happen? Notice that they give you the non-regularized term of each of the gradients and you just have to add the extra term for the regularization.

Update: yes, I just omitted all the regularization terms and I get exactly the answers you show. Please have a more careful look at the instructions and the code.

1 Like

Thanks for your support. It’s now fixed.

Thanks,

Elango