I’m trying to complete the pool_forward function but I keep getting an error for an array size along with my answers being incorrect. I’m a bit confused with it so if someone could take a look I’d appreciate it:
mode = max
A.shape = (2, 3, 3, 3)
A[1, 1] =
[[ 0.16938243 0.74055645 -0.9537006 ]
[ 0.31515939 0.84616065 -0.85951594]
[-1.61577235 1.12141771 0.40890054]]
mode = average
A.shape = (2, 3, 3, 3)
A[1, 1] =
[[ 0.16938243 0.74055645 -0.9537006 ]
[ 0.31515939 0.84616065 -0.85951594]
[-1.61577235 1.12141771 0.40890054]]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-39-dd4190c83221> in <module>
14 print("A[1, 1] =\n", A[1, 1])
15
---> 16 pool_forward_test(pool_forward)
~/work/release/W1A1/public_tests.py in pool_forward_test(target)
125 # Test 1
126 A_prev = np.random.randn(2, 5, 7, 3)
--> 127 A, cache = target(A_prev, {"stride" : 2, "f": 2}, mode = "average")
128 A_shape = A.shape
129 assert A_shape[0] == A_prev.shape[0], f"Test 1 - m is wrong. Current: {A_shape[0]}. Expected: {A_prev.shape[0]}"
<ipython-input-38-7638be32f6e5> in pool_forward(A_prev, hparameters, mode)
67 A[i, h, w, c] = np.max(a_prev_slice[i, h, w, c])
68 elif mode == 'average':
---> 69 A[i, h, w, c] = np.mean(a_prev_slice[i, h, w, c])
70
71 # YOUR CODE ENDS HERE
IndexError: index 2 is out of bounds for axis 2 with size 2