Course 4 Week 1 CNN Exercise 8 Stuck in average pooling

In Exercise 8 of Programming Assignment 1, there is an optional assignment to implement pool_backward. I was able to write the code and the dimensions look fine. I was able to get the pooling for max mode right. But I am stuck on the average mode.

I am pretty sure that the error is when I am getting the da value from dA. I tried setting da=1. But that didnt work. I tried setting da = np.sum(dA). But that also doesnt work.

This is the error that I am getting

(5, 4, 2, 2)
(5, 5, 3, 2)
mode = max
mean of dA =  0.14571390272918056
dA_prev1[1,1] =  [[ 0.          0.        ]
 [ 5.05844394 -1.68282702]
 [ 0.          0.        ]]

mode = average
mean of dA =  0.14571390272918056
dA_prev2[1,1] =  [[ 5.82855611  5.82855611]
 [11.65711222 11.65711222]
 [ 5.82855611  5.82855611]]
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-22-14e1d5abab7e> in <module>
     24 assert np.allclose(dA_prev2[1, 1], [[0.08485462,  0.2787552], 
     25                                     [1.26461098, -0.25749373],
---> 26                                     [1.17975636, -0.53624893]]), "Wrong values for mode average"
     27 print("\033[92m All tests passed.")

AssertionError: Wrong values for mode average

Hi rivaskh,

Sorry for the late response. Is this still an issue or should we close it?

Best,

Rosa