Hello!
So I read and re-read every post previously written about this excercise and still can’t figure it out.
The value for AL seems correct: [[0.03921668 0.70498921 0.19734387 0.04728177]]
However I am getting these infamous “Wrong Shape for variable 0,1,2…” errors.
And the error: The function should return a numpy array. in variable 1. Got type: <class ‘list’> but expected type <class ‘list’>
I added print statements after each layer is calculated in the for loop and in the final layer. The dimensions of A seem to be right. I suspect it has to be something with the cache but I don’t even know where to start digging.
Anyone might have a hint?
Thanks!!
After layer 1, A is [[0. 3.18040136 0.4074501 0. ]
[0. 0. 3.18141623 0. ]
[4.18500916 0. 0. 2.72141638]
[5.05850802 0. 0. 3.82321852]]
After layer 2, A is [[ 2.2644603 1.09971298 0. 1.54036335]
[ 6.33722569 0. 0. 4.48582383]
[10.37508342 0. 1.63635185 8.17870169]]
After layer 2,cache is ((array([[0. , 3.18040136, 0.4074501 , 0. ],
[0. , 0. , 3.18141623, 0. ],
[4.18500916, 0. , 0. , 2.72141638],
[5.05850802, 0. , 0. , 3.82321852]]), array([[-0.12673638, -1.36861282, 1.21848065, -0.85750144],
[-0.56147088, -1.0335199 , 0.35877096, 1.07368134],
[-0.37550472, 0.39636757, -0.47144628, 2.33660781]]), array([[ 1.50278553],
[-0.59545972],
[ 0.52834106]])), array([[ 2.2644603 , 1.09971298, -2.90298027, 1.54036335],
[ 6.33722569, -2.38116246, -4.11228806, 4.48582383],
[10.37508342, -0.66591468, 1.63635185, 8.17870169]]))
After layer 3, AL is [[0.03921668 0.70498921 0.19734387 0.04728177]] and cache is ((array([[ 2.2644603 , 1.09971298, 0. , 1.54036335],
[ 6.33722569, 0. , 0. , 4.48582383],
[10.37508342, 0. , 1.63635185, 8.17870169]]), array([[ 0.9398248 , 0.42628539, -0.75815703]]), array([[-0.16236698]])), array([[-3.19864676, 0.87117055, -1.40297864, -3.00319435]]))
AL = [[0.03921668 0.70498921 0.19734387 0.04728177]]
After layer 1, A is [[0. 3.18040136 0.4074501 0. ]
[0. 0. 3.18141623 0. ]
[4.18500916 0. 0. 2.72141638]
[5.05850802 0. 0. 3.82321852]]
After layer 2, A is [[ 2.2644603 1.09971298 0. 1.54036335]
[ 6.33722569 0. 0. 4.48582383]
[10.37508342 0. 1.63635185 8.17870169]]
After layer 2,cache is ((array([[0. , 3.18040136, 0.4074501 , 0. ],
[0. , 0. , 3.18141623, 0. ],
[4.18500916, 0. , 0. , 2.72141638],
[5.05850802, 0. , 0. , 3.82321852]]), array([[-0.12673638, -1.36861282, 1.21848065, -0.85750144],
[-0.56147088, -1.0335199 , 0.35877096, 1.07368134],
[-0.37550472, 0.39636757, -0.47144628, 2.33660781]]), array([[ 1.50278553],
[-0.59545972],
[ 0.52834106]])), array([[ 2.2644603 , 1.09971298, -2.90298027, 1.54036335],
[ 6.33722569, -2.38116246, -4.11228806, 4.48582383],
[10.37508342, -0.66591468, 1.63635185, 8.17870169]]))
After layer 3, AL is [[0.03921668 0.70498921 0.19734387 0.04728177]] and cache is ((array([[ 2.2644603 , 1.09971298, 0. , 1.54036335],
[ 6.33722569, 0. , 0. , 4.48582383],
[10.37508342, 0. , 1.63635185, 8.17870169]]), array([[ 0.9398248 , 0.42628539, -0.75815703]]), array([[-0.16236698]])), array([[-3.19864676, 0.87117055, -1.40297864, -3.00319435]]))
Error: The function should return a numpy array. in variable 1. Got type: <class 'list'> but expected type <class 'list'>
After layer 1, A is [[0. 3.18040136 0.4074501 0. ]
[0. 0. 3.18141623 0. ]
[4.18500916 0. 0. 2.72141638]
[5.05850802 0. 0. 3.82321852]]
After layer 2, A is [[ 2.2644603 1.09971298 0. 1.54036335]
[ 6.33722569 0. 0. 4.48582383]
[10.37508342 0. 1.63635185 8.17870169]]
After layer 2,cache is ((array([[0. , 3.18040136, 0.4074501 , 0. ],
[0. , 0. , 3.18141623, 0. ],
[4.18500916, 0. , 0. , 2.72141638],
[5.05850802, 0. , 0. , 3.82321852]]), array([[-0.12673638, -1.36861282, 1.21848065, -0.85750144],
[-0.56147088, -1.0335199 , 0.35877096, 1.07368134],
[-0.37550472, 0.39636757, -0.47144628, 2.33660781]]), array([[ 1.50278553],
[-0.59545972],
[ 0.52834106]])), array([[ 2.2644603 , 1.09971298, -2.90298027, 1.54036335],
[ 6.33722569, -2.38116246, -4.11228806, 4.48582383],
[10.37508342, -0.66591468, 1.63635185, 8.17870169]]))
After layer 3, AL is [[0.03921668 0.70498921 0.19734387 0.04728177]] and cache is ((array([[ 2.2644603 , 1.09971298, 0. , 1.54036335],
[ 6.33722569, 0. , 0. , 4.48582383],
[10.37508342, 0. , 1.63635185, 8.17870169]]), array([[ 0.9398248 , 0.42628539, -0.75815703]]), array([[-0.16236698]])), array([[-3.19864676, 0.87117055, -1.40297864, -3.00319435]]))
Error: Wrong shape for variable 0.
Error: Wrong shape for variable 1.
Error: Wrong shape for variable 2.
Error: Wrong shape for variable 1.
Error: Wrong shape for variable 0.
Error: Wrong shape for variable 1.
Error: Wrong shape for variable 2.
Error: Wrong shape for variable 1.
Error: Wrong shape for variable 2.
After layer 1, A is [[0. 3.18040136 0.4074501 0. ]
[0. 0. 3.18141623 0. ]
[4.18500916 0. 0. 2.72141638]
[5.05850802 0. 0. 3.82321852]]
After layer 2, A is [[ 2.2644603 1.09971298 0. 1.54036335]
[ 6.33722569 0. 0. 4.48582383]
[10.37508342 0. 1.63635185 8.17870169]]
After layer 2,cache is ((array([[0. , 3.18040136, 0.4074501 , 0. ],
[0. , 0. , 3.18141623, 0. ],
[4.18500916, 0. , 0. , 2.72141638],
[5.05850802, 0. , 0. , 3.82321852]]), array([[-0.12673638, -1.36861282, 1.21848065, -0.85750144],
[-0.56147088, -1.0335199 , 0.35877096, 1.07368134],
[-0.37550472, 0.39636757, -0.47144628, 2.33660781]]), array([[ 1.50278553],
[-0.59545972],
[ 0.52834106]])), array([[ 2.2644603 , 1.09971298, -2.90298027, 1.54036335],
[ 6.33722569, -2.38116246, -4.11228806, 4.48582383],
[10.37508342, -0.66591468, 1.63635185, 8.17870169]]))
After layer 3, AL is [[0.03921668 0.70498921 0.19734387 0.04728177]] and cache is ((array([[ 2.2644603 , 1.09971298, 0. , 1.54036335],
[ 6.33722569, 0. , 0. , 4.48582383],
[10.37508342, 0. , 1.63635185, 8.17870169]]), array([[ 0.9398248 , 0.42628539, -0.75815703]]), array([[-0.16236698]])), array([[-3.19864676, 0.87117055, -1.40297864, -3.00319435]]))
Error: Wrong output for variable 0.
Error: Wrong output for variable 1.
Error: Wrong output for variable 2.
Error: Wrong output for variable 1.
Error: Wrong output for variable 0.
Error: Wrong output for variable 1.
Error: Wrong output for variable 2.
Error: Wrong output for variable 1.
Error: Wrong output for variable 2.
0 Tests passed
3 Tests failed
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-34-10fc901e800a> in <module>
4 print("AL = " + str(t_AL))
5
----> 6 L_model_forward_test(L_model_forward)
~/work/release/W4A1/public_tests.py in L_model_forward_test(target)
238 ]
239
--> 240 multiple_test(test_cases, target)
241 ''' {
242 "name":"datatype_check",
~/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_forward. Check your equations and avoid using global variables inside the function.