My error message is below. The way to compute a_prev, vert_start, vert_end, horiz_start and horiz_end, a_prev_slice are the same as those in conv_forward, and np.max/mean simply applies to a_prev_slice. I don’t know why this error occurs.
mode = max
A.shape = (2, 3, 3, 3)
A[1, 1] =
[[2.10025514 2.10025514 2.10025514]
[2.10025514 2.10025514 2.10025514]
[2.10025514 2.10025514 2.10025514]]
mode = average
A.shape = (2, 3, 3, 3)
A[1, 1] =
[[-0.04193968 -0.04193968 -0.04193968]
[-0.04193968 -0.04193968 -0.04193968]
[-0.04193968 -0.04193968 -0.04193968]]
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-31-034ff9e73c4d> in <module>
13 print("A[1, 1] =\n", A[1, 1])
14
---> 15 pool_forward_test(pool_forward)
~/work/release/W1A1/public_tests.py in pool_forward_test(target)
152 [0.31515939, 0.84616065, 0.07734007],
153 [0.69803203, 0.84616065, 1.2245077 ],
--> 154 [0.69803203, 1.12141771, 1.2245077 ]])), "Wrong value for A[1, 1]"
155
156 assert np.allclose(cache[0][1, 2], np.array([[ 0.16938243, 0.74055645, -0.9537006 ],
AssertionError: Wrong value for A[1, 1]
The expected output is:
Expected output
mode = max
A.shape = (2, 3, 3, 3)
A[1, 1] =
[[1.96710175 0.84616065 1.27375593]
[1.96710175 0.84616065 1.23616403]
[1.62765075 1.12141771 1.2245077 ]]
mode = average
A.shape = (2, 3, 3, 3)
A[1, 1] =
[[ 0.44497696 -0.00261695 -0.31040307]
[ 0.50811474 -0.23493734 -0.23961183]
[ 0.11872677 0.17255229 -0.22112197]]