DLS4 - Week1- Exercise 8 -pool_backward

Hi,

I am getting below error-

(5, 4, 2, 2)
(5, 5, 3, 2)

ValueError Traceback (most recent call last)
in
7 dA = np.random.randn(5, 4, 2, 2)
8
----> 9 dA_prev1 = pool_backward(dA, cache, mode = “max”)
10 print(“mode = max”)
11 print('mean of dA = ', np.mean(dA))

in pool_backward(dA, cache, mode)
85 a_prev_slice = a_prev[vert_start:vert_end,horiz_start:horiz_end,c]
86 mask = create_mask_from_window(a_prev_slice)
—> 87 dA_prev[i, vert_start: vert_end, horiz_start: horiz_end, c] += dA_prev[i, h, w, c] + mask
88 elif mode == “average”:
89 da = distribute_value(dA, (n_H,n_W))

ValueError: non-broadcastable output operand with shape (2,1) doesn’t match the broadcast shape (2,2)

Please help me out to find the mistake

I have the same problem!
I think you should multiply mask and dA_prev. But this does not help to fix error!

I figure out the problem by printing the
mask.shape
dA[?,?,?,?].shape

It turned out that in the initial step to set shape, I mis-input the parameters.