Regularizatio dropout exercise forward prpogation test case

Test case gives the output for A3 as
A3 = np.array([[0.36974721, 0.00305176, 0.04565099, 0.49683389, 0.36974721]])
A3 is also a part of cache in which it is
array([[0.49683389, 0.05332327, 0.04565099, 0.01446893, 0.49683389]])
One of them needs to be wrong.
Which one. I have been struck in this for the last one week. Can somebody help?

Hi @vss,

I’m assuming that you are working on week 1, assignment 2, exercise 3.

There you have a direct assignment to cache after computation of A3.

    A3 = sigmoid(Z3)

    cache = (Z1, D1, A1, W1, b1, Z2, D2, A2, W2, b2, Z3, A3, W3, b3)
    
    return A3, cache

So, I don’t see how they can be different, unless there is some global variable or some extra computation doing afterwards. The test show you A3, where are you displaying cache?

This is i the course 2, Regularizatio lab. I got the values from the test cases in public_test.py and displaying i my jupyter book.
my output with print statements are as follows:
A1= [[0. 4.75035192 3.05706487 3.72429505 0. ]
[0. 0. 1.1293003 2.09276446 0. ]]
A2= [[0. 4.16768631 4.40550021 6.12438851 0. ]
[0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. ]]
A3= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
cache= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
A3 = [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
A1= [[0. 4.75035192 3.05706487 3.72429505 0. ]
[0. 0. 1.1293003 2.09276446 0. ]]
A2= [[0. 4.16768631 4.40550021 6.12438851 0. ]
[0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. ]]
A3= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
cache= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
A1= [[0. 4.75035192 3.05706487 3.72429505 0. ]
[0. 0. 1.1293003 2.09276446 0. ]]
A2= [[0. 4.16768631 4.40550021 6.12438851 0. ]
[0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. ]]
A3= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
cache= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
1 Tests passed
1 Tests failed
If my A3 or cache is wrong value my backward propogation test should have failed. But t passed as follows:
dA1 =
[[ 0.36544439 0. -0.00188233 0. -0.17408748]
[ 0.65515713 0. -0.00337459 0. -0. ]]
dA2 =
[[ 0.58180856 0. -0.00299679 0. -0.27715731]
[ 0. 0.53159854 -0. 0.53159854 -0.34089673]
[ 0. 0. -0.00292733 0. -0. ]]
All tests passed.
So I believe the values in cache must have been correct. Not sure why the test case i forward prop failed. The test case in forward prop has A3 value as

A3 = np.array([[0.36974721, 0.00305176, 0.04565099, 0.49683389, 0.36974721]])
cache = (np.array([[-1.52855314,  3.32524635,  2.13994541,  2.60700654, -0.75942115],
    [-1.98043538,  4.1600994 ,  0.79051021,  1.46493512, -0.45506242]]),

np.array([[ True, False, True, True, True],
[ True, True, True, True, True]]),
np.array([[0. , 0. , 3.05706487, 3.72429505, 0. ],
[0. , 5.94299915, 1.1293003 , 2.09276446, 0. ]]),
np.array([[-1.09989127, -0.17242821, -0.87785842],
[ 0.04221375, 0.58281521, -1.10061918]]),
np.array([[1.14472371],
[0.90159072]]),
np.array([[ 0.53035547, 5.88414161, 3.08385015, 4.28707196, 0.53035547],
[-0.69166075, -1.42199726, -2.92064114, -3.49524533, -0.69166075],
[-0.39675353, -1.98881216, -3.55998747, -4.44246165, -0.39675353]]),
np.array([[ True, True, True, False, True],
[ True, True, True, True, True],
[False, False, True, True, False]]),
np.array([[0.75765067, 8.40591658, 4.40550021, 0. , 0.75765067],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ]]),
np.array([[ 0.50249434, 0.90085595],
[-0.68372786, -0.12289023],
[-0.93576943, -0.26788808]]),
np.array([[ 0.53035547],
[-0.69166075],
[-0.39675353]]),
np.array([[-0.53330145, -5.78898099, -3.04000407, -0.0126646 , -0.53330145]]),
np.array([[0.36974721, 0.00305176, 0.04565099, 0.49683389, 0.36974721]]),
np.array([[-0.6871727 , -0.84520564, -0.67124613]]),
np.array([[-0.0126646]]))
keep_prob = 0.7
expected_output = (A3, cache)
In my opinion cache expected and actual as per my output match. So what is failing?

vss

3m

This is i the course 2, Regularizatio lab. I got the values from the test cases in public_test.py and displaying i my jupyter book.
my output with print statements are as follows:
A1= [[0. 4.75035192 3.05706487 3.72429505 0. ]
[0. 0. 1.1293003 2.09276446 0. ]]
A2= [[0. 4.16768631 4.40550021 6.12438851 0. ]
[0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. ]]
A3= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
cache= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
A3 = [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
A1= [[0. 4.75035192 3.05706487 3.72429505 0. ]
[0. 0. 1.1293003 2.09276446 0. ]]
A2= [[0. 4.16768631 4.40550021 6.12438851 0. ]
[0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. ]]
A3= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
cache= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
A1= [[0. 4.75035192 3.05706487 3.72429505 0. ]
[0. 0. 1.1293003 2.09276446 0. ]]
A2= [[0. 4.16768631 4.40550021 6.12438851 0. ]
[0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. ]]
A3= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
cache= [[0.49683389 0.05332327 0.04565099 0.01446893 0.49683389]]
1 Tests passed
1 Tests failed
If my A3 or cache is wrong value my backward propogation test should have failed. But t passed as follows:
dA1 =
[[ 0.36544439 0. -0.00188233 0. -0.17408748]
[ 0.65515713 0. -0.00337459 0. -0. ]]
dA2 =
[[ 0.58180856 0. -0.00299679 0. -0.27715731]
[ 0. 0.53159854 -0. 0.53159854 -0.34089673]
[ 0. 0. -0.00292733 0. -0. ]]
All tests passed.
So I believe the values in cache must have been correct. Not sure why the test case i forward prop failed. The test case in forward prop has A3 value as

A3 = np.array([[0.36974721, 0.00305176, 0.04565099, 0.49683389, 0.36974721]])
cache = (np.array([[-1.52855314,  3.32524635,  2.13994541,  2.60700654, -0.75942115],
    [-1.98043538,  4.1600994 ,  0.79051021,  1.46493512, -0.45506242]]),

np.array([[ True, False, True, True, True],
[ True, True, True, True, True]]),
np.array([[0. , 0. , 3.05706487, 3.72429505, 0. ],
[0. , 5.94299915, 1.1293003 , 2.09276446, 0. ]]),
np.array([[-1.09989127, -0.17242821, -0.87785842],
[ 0.04221375, 0.58281521, -1.10061918]]),
np.array([[1.14472371],
[0.90159072]]),
np.array([[ 0.53035547, 5.88414161, 3.08385015, 4.28707196, 0.53035547],
[-0.69166075, -1.42199726, -2.92064114, -3.49524533, -0.69166075],
[-0.39675353, -1.98881216, -3.55998747, -4.44246165, -0.39675353]]),
np.array([[ True, True, True, False, True],
[ True, True, True, True, True],
[False, False, True, True, False]]),
np.array([[0.75765067, 8.40591658, 4.40550021, 0. , 0.75765067],
[0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. ]]),
np.array([[ 0.50249434, 0.90085595],
[-0.68372786, -0.12289023],
[-0.93576943, -0.26788808]]),
np.array([[ 0.53035547],
[-0.69166075],
[-0.39675353]]),
np.array([[-0.53330145, -5.78898099, -3.04000407, -0.0126646 , -0.53330145]]),
np.array([[0.36974721, 0.00305176, 0.04565099, 0.49683389, 0.36974721]]),
np.array([[-0.6871727 , -0.84520564, -0.67124613]]),
np.array([[-0.0126646]]))
keep_prob = 0.7
expected_output = (A3, cache)
In my opinion cache expected and actual as per my output match. So what is failing?