Note that the shape of your AL value is even wrong. It should be 1 x 4, but yours is 3 x 4. Also notice that the test throws lots of other errors. I think you should step back and start by looking at the “dimensional analysis” on this test case. Here’s a thread about that.
Then I added print statements to my code to show the intermediate results at all the layers. Try adding similar prints and compare your values.
A1 = [[0. 3.18040136 0.4074501 0. ]
[0. 0. 3.18141623 0. ]
[4.18500916 0. 0. 2.72141638]
[5.05850802 0. 0. 3.82321852]]
A2 = [[ 2.2644603 1.09971298 0. 1.54036335]
[ 6.33722569 0. 0. 4.48582383]
[10.37508342 0. 1.63635185 8.17870169]]
A3 = [[0.03921668 0.70498921 0.19734387 0.04728177]]
AL = [[0.03921668 0.70498921 0.19734387 0.04728177]]
A1 = [[0. 3.18040136 0.4074501 0. ]
[0. 0. 3.18141623 0. ]
[4.18500916 0. 0. 2.72141638]
[5.05850802 0. 0. 3.82321852]]
A2 = [[ 2.2644603 1.09971298 0. 1.54036335]
[ 6.33722569 0. 0. 4.48582383]
[10.37508342 0. 1.63635185 8.17870169]]
A3 = [[0.03921668 0.70498921 0.19734387 0.04728177]]
A1 = [[0. 3.18040136 0.4074501 0. ]
[0. 0. 3.18141623 0. ]
[4.18500916 0. 0. 2.72141638]
[5.05850802 0. 0. 3.82321852]]
A2 = [[ 2.2644603 1.09971298 0. 1.54036335]
[ 6.33722569 0. 0. 4.48582383]
[10.37508342 0. 1.63635185 8.17870169]]
A3 = [[0.03921668 0.70498921 0.19734387 0.04728177]]
A1 = [[0. 3.18040136 0.4074501 0. ]
[0. 0. 3.18141623 0. ]
[4.18500916 0. 0. 2.72141638]
[5.05850802 0. 0. 3.82321852]]
A2 = [[ 2.2644603 1.09971298 0. 1.54036335]
[ 6.33722569 0. 0. 4.48582383]
[10.37508342 0. 1.63635185 8.17870169]]
A3 = [[0.03921668 0.70498921 0.19734387 0.04728177]]
All tests passed.
Note that the test cell runs a bunch of tests besides the “2hidden” one. Just try analyzing the first set of A1 to A3 values. Perhaps this counts as belaboring the obvious, but the fundamental point of forward propagation is that the output of each layer is the input to the next one. So as soon as one of them is wrong, everything further down the line is doomed.