(2, 1)
(2, 3)
(2, 1)
(2, 3)
(2, 2)
(2, 3)
ValueError Traceback (most recent call last)
in
----> 1 params, grads, costs = optimize(w, b, X, Y, num_iterations=100, learning_rate=0.009, print_cost=False)
2
3 print ("w = " + str(params[“w”]))
4 print ("b = " + str(params[“b”]))
5 print ("dw = " + str(grads[“dw”]))
in optimize(w, b, X, Y, num_iterations, learning_rate, print_cost)
41 print(X.shape)
42 # w=w.reshape(X[0].shape,1)
—> 43 grads, cost = propagate(w, b, X, Y)
44
45
in propagate(w, b, X, Y)
36 # assert w.shape == (X.shape[0], 1)
37 # w = w.reshape(X.shape[0], 1)
—> 38 A=sigmoid(np.dot(w.T,X)+b)
39 cost=-1/mnp.sum(Ynp.log(A)+(1-Y)*np.log(1-A))
40 ‘’'Here’s why we need to use element-wise multiplication instead of dot product in the cost calculation:
ValueError: operands could not be broadcast together with shapes (2,3) (2,2) .
I am getting this error while running the optimize function.
im printing the size of w then X.
so in the first two iterations the size of w is 2,1 its fine ,but in the third iteration its becoming 2,2.
i even tried resizing it to 2,1 (now commented part) but it says cannot resize an array of size 4.
im not understanding the root cause for this and am rly stuck, any feedback will be greatly appreciated.