# Help! Exercise 5 not working!

Moderator edit: code removed.

## w = np.array([[1.], [2]]) b = 1.5 X = np.array([[1., -2., -1.], [3., 0.5, -3.2]]) Y = np.array([[1, 1, 0]]) grads, cost = propagate(w, b, X, Y) ​ assert type(grads[“dw”]) == np.ndarray assert grads[“dw”].shape == (2, 1) assert type(grads[“db”]) == np.float64 ​ ​ print ("dw = " + str(grads[“dw”])) print ("db = " + str(grads[“db”])) print ("cost = " + str(cost)) ​ propagate_test(propagate) dw = [[-0.08611258] [-1.40039089]] db = 0.0010854697265789692 cost = 1.0980507252610077

ValueError Traceback (most recent call last)
in
14 print ("cost = " + str(cost))
15
—> 16 propagate_test(propagate)

~/work/release/W2A2/public_tests.py in propagate_test(target)
36
—> 37 grads, cost = target( w, b, X, Y)
38

in propagate(w, b, X, Y)
33 A = sigmoid(np.dot(w.T,X) + b)
34
—> 35 cost = -1/m * np.sum(Y * np.log(A) + (1-Y)*np.log(1-A))
36
37 # YOUR CODE ENDS HERE

ValueError: operands could not be broadcast together with shapes (1,4) (3,)

For element wise multiplication, `*` to be done, both operands should be the same shape. Given that Y.shape = (1, 3), please check your sigmoid implementation.

Hi, @Ivan_Carbone. The traceback indicates (btw, no posting of code allowed) that the shapes of `A` and `Y` do not conform to matrix multiplication. It looks like your problem might be further up the stack. Since `A` is generated by your `sigmoid()` function, first verify that that function passed its tests. with the expected output.

You were totally right. I was giving the sigmoid() function a wrong argument.

Thank you very much, and I’m sorry for posting the code. Have a good 2022!!