# Exercise 5 - L_model_forward - Stuck here for weeks!

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.
``````

Have you seen this thread about the dimensional analysis for this test case?

Also have you looked at the test code to see what it is actually checking? It does check the caches as well. I agree that your A^{[l]} shapes look correct, so the caches are the place to look. But the key is you need to understand what they look like, right? At each layer, it is:

`((A, W, b), Z)`

So there are two entries at the outer level and the first one is (A, W, b) for that layer, but the key is that the A value is the input, right? Not the output. So for layer 1, the output is A1, but the input was A0 (which is X).

1 Like

Notice that in your results, you don’t show the caches after layer 1 or layer 3. But the shapes of your cache entries in layer 2 look correct and the mechanisms should be the same.

Thank you @paulinpaloalto ! I corrected the print statements so the reflect better what’s going on, if you see below, the values for each cache calculated are the same as the expected cache for each layer. I feel like I am close but just not there…
At the end, I made a print of the final caches list (the one that is built by appending each calculated cache on every layer). That list looks pretty bad, so I assume my error has to be in the append part.

``````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 1,cache is ((array([[-0.31178367,  0.72900392,  0.21782079, -0.8990918 ],
[-2.48678065,  0.91325152,  1.12706373, -1.51409323],
[ 1.63929108, -0.4298936 ,  2.63128056,  0.60182225],
[-0.33588161,  1.23773784,  0.11112817,  0.12915125],
[ 0.07612761, -0.15512816,  0.63422534,  0.810655  ]]), array([[ 0.35480861,  1.81259031, -1.3564758 , -0.46363197,  0.82465384],
[-1.17643148,  1.56448966,  0.71270509, -0.1810066 ,  0.53419953],
[-0.58661296, -1.48185327,  0.85724762,  0.94309899,  0.11444143],
[-0.02195668, -2.12714455, -0.83440747, -0.46550831,  0.23371059]]), array([[ 1.38503523],
[-0.51962709],
[-0.78015214],
[ 0.95560959]])), array([[-5.23825714,  3.18040136,  0.4074501 , -1.88612721],
[-2.77358234, -0.56177316,  3.18141623, -0.99209432],
[ 4.18500916, -1.78006909, -0.14502619,  2.72141638],
[ 5.05850802, -1.25674082, -3.54566654,  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]]))
The final Caches list 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]])), ((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 1,cache is ((array([[-0.31178367,  0.72900392,  0.21782079, -0.8990918 ],
[-2.48678065,  0.91325152,  1.12706373, -1.51409323],
[ 1.63929108, -0.4298936 ,  2.63128056,  0.60182225],
[-0.33588161,  1.23773784,  0.11112817,  0.12915125],
[ 0.07612761, -0.15512816,  0.63422534,  0.810655  ]]), array([[ 0.35480861,  1.81259031, -1.3564758 , -0.46363197,  0.82465384],
[-1.17643148,  1.56448966,  0.71270509, -0.1810066 ,  0.53419953],
[-0.58661296, -1.48185327,  0.85724762,  0.94309899,  0.11444143],
[-0.02195668, -2.12714455, -0.83440747, -0.46550831,  0.23371059]]), array([[ 1.38503523],
[-0.51962709],
[-0.78015214],
[ 0.95560959]])), array([[-5.23825714,  3.18040136,  0.4074501 , -1.88612721],
[-2.77358234, -0.56177316,  3.18141623, -0.99209432],
[ 4.18500916, -1.78006909, -0.14502619,  2.72141638],
[ 5.05850802, -1.25674082, -3.54566654,  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]]))
The final Caches list 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]])), ((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 1,cache is ((array([[-0.31178367,  0.72900392,  0.21782079, -0.8990918 ],
[-2.48678065,  0.91325152,  1.12706373, -1.51409323],
[ 1.63929108, -0.4298936 ,  2.63128056,  0.60182225],
[-0.33588161,  1.23773784,  0.11112817,  0.12915125],
[ 0.07612761, -0.15512816,  0.63422534,  0.810655  ]]), array([[ 0.35480861,  1.81259031, -1.3564758 , -0.46363197,  0.82465384],
[-1.17643148,  1.56448966,  0.71270509, -0.1810066 ,  0.53419953],
[-0.58661296, -1.48185327,  0.85724762,  0.94309899,  0.11444143],
[-0.02195668, -2.12714455, -0.83440747, -0.46550831,  0.23371059]]), array([[ 1.38503523],
[-0.51962709],
[-0.78015214],
[ 0.95560959]])), array([[-5.23825714,  3.18040136,  0.4074501 , -1.88612721],
[-2.77358234, -0.56177316,  3.18141623, -0.99209432],
[ 4.18500916, -1.78006909, -0.14502619,  2.72141638],
[ 5.05850802, -1.25674082, -3.54566654,  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]]))
The final Caches list 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]])), ((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 1,cache is ((array([[-0.31178367,  0.72900392,  0.21782079, -0.8990918 ],
[-2.48678065,  0.91325152,  1.12706373, -1.51409323],
[ 1.63929108, -0.4298936 ,  2.63128056,  0.60182225],
[-0.33588161,  1.23773784,  0.11112817,  0.12915125],
[ 0.07612761, -0.15512816,  0.63422534,  0.810655  ]]), array([[ 0.35480861,  1.81259031, -1.3564758 , -0.46363197,  0.82465384],
[-1.17643148,  1.56448966,  0.71270509, -0.1810066 ,  0.53419953],
[-0.58661296, -1.48185327,  0.85724762,  0.94309899,  0.11444143],
[-0.02195668, -2.12714455, -0.83440747, -0.46550831,  0.23371059]]), array([[ 1.38503523],
[-0.51962709],
[-0.78015214],
[ 0.95560959]])), array([[-5.23825714,  3.18040136,  0.4074501 , -1.88612721],
[-2.77358234, -0.56177316,  3.18141623, -0.99209432],
[ 4.18500916, -1.78006909, -0.14502619,  2.72141638],
[ 5.05850802, -1.25674082, -3.54566654,  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]]))
The final Caches list 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]])), ((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-21-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.
``````

Update! I got it right! I can’t believe it was such a simple error… I had not indented the list.append part inside the for loop, so it was outside the for loop and not appended correctly.

Thank you so much for helping me!

It’s great to hear that you were able to figure out the issue based on those clues. Nice work!