I’m struggling with the pool_backward function. I’m getting the correct mean values, but my dA_prev[1, 1]s are off a bit. I can’t figure out where I’m going wrong. Any help is appreciated. Here’s my code (I assume it’s ok to share it since the exercise is ungraded):
{moderator edit - solution code removed}
And here the results:
(5, 4, 2, 2)
(5, 5, 3, 2)
mode = max
mean of dA = 0.14571390272918056
dA_prev1[1,1] = [[ 0. 0. ]
[10.11330283 -0.49726956]
[ 0. 0. ]]
mode = average
mean of dA = 0.14571390272918056
dA_prev2[1,1] = [[-0.32345834 0.45074345]
[ 2.52832571 -0.24863478]
[ 1.26416285 -0.12431739]]
Right! The point is that the way the loops work here is exactly analogous to how they work in forward propagation: the loops are over the output space and there is just one entry in the output space at every position. But that is mapped from (in the forward case) or to (in the backward case) a filter patch area in the input space.