When creating a post, please add:
- Week # must be added in the tags option of the post.
- Link to the classroom item you are referring to:https://www.coursera.org/learn/neural-networks-deep-learning/programming/GY8CB/building-your-deep-neural-network-step-by-step/lab?path=%2Fnotebooks%2Frelease%2FW4A1%2FBuilding_your_Deep_Neural_Network_Step_by_Step.ipynb
- Description (include relevant info but please do not post solution code or your entire notebook)
My code is below for this function:
{moderator edit - solution code removed}
The result is that I pass 2/3 tests. The output is:
t_AL, t_Y_assess, t_caches = L_model_backward_test_case()
grads = L_model_backward(t_AL, t_Y_assess, t_caches)
print("dA0 = " + str(grads[‘dA0’]))
print("dA1 = " + str(grads[‘dA1’]))
print("dW1 = " + str(grads[‘dW1’]))
print("dW2 = " + str(grads[‘dW2’]))
print("db1 = " + str(grads[‘db1’]))
print("db2 = " + str(grads[‘db2’]))
L_model_backward_test(L_model_backward)
dA0 = [[ 0.09649747 -1.8634927 ]
[-0.2773882 -0.35475898]
[-0.08274148 -0.62700068]
[-0.04381817 -0.47721803]]
dA1 = [[ 1.97611078 -1.24412333]
[-0.62641691 -0.80376609]
[-2.41908317 -0.92379202]]
dW1 = [[-1.31386475 0.88462238 0.88131804 1.70957306]
[ 0.05003364 -0.40467741 -0.54535995 -1.54647732]
[ 0.98236743 -1.10106763 -1.18504653 -0.2056499 ]]
dW2 = [[-1.02387576 1.12397796 -0.13191423]]
db1 = [[ 1.48614836]
[ 0.23671627]
[-1.02378514]]
db2 = [[-1.62328545]]
Error: Wrong output for variable dA1.
Error: Wrong output for variable dW2.
Error: Wrong output for variable db2.
Error: Wrong output for variable dA0.
Error: Wrong output for variable dW1.
Error: Wrong output for variable db1.
2 Tests passed
1 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)
533 ]
534
→ 535 multiple_test(test_cases, target)
536
537
~/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.
Expected output:
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]]
Please assist.
Thank you,
Ken