Week 1 ex2 foward propagation with drop out

hello, everyone, I found it is hard to get the d dimension right, any one can help me with that?

(2, 5)

ValueError Traceback (most recent call last)
1 t_X, parameters = forward_propagation_with_dropout_test_case()
----> 3 A3, cache = forward_propagation_with_dropout(t_X, parameters, keep_prob=0.7)
4 print ("A3 = " + str(A3))

in forward_propagation_with_dropout(X, parameters, keep_prob)
[Removed solution code]
—> 45 A1 = A1 * D1

ValueError: operands could not be broadcast together with shapes (2,5) (3,5)

Hi, @AndrewXue.

You initialized D1 with the correct shape, but by the time you try to multiply it element-wise with A1 it has the same shape as X. Can you see where the problem is? :slight_smile:

@nramon Getting the same error but with different dimensions . Unable to figure it out .

Fixed by @A_12_EESHAN_BHANAP.

If A1 and D1 have different shapes, NumPy will try to broadcast them to a common shape, hence the operands could not be broadcast together error.

Good luck with the rest of the assignment :slight_smile:

1 Like