Comput cost in C1_W3_Logistic_Regression

i am doing an np.matmul of w an x and then adding b to get z. python does not like my matmul (please see beow).

the shapes look ok:
w,x,b <class ‘numpy.ndarray’> <class ‘numpy.ndarray’> <class ‘float’>
w,x,b (2,) (100, 2) 0.0

can any one see the problem.?

do i need to do a reshape or a transpose?

thanks

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 100 is different from 2)

You have the arguments in the wrong order, you can’t multiply (2,) by (100,2). Try flipping the order.

i will give that a try. i just cancelled this and two other specializations due to cost, so i can not access now, but i will when i come back. thank you.

seems like i have access for a t leas a few more days. i get the folloewin:

using w and X gets a value error the a dimension mismatch.
using w.T and X gets a value error the a dimension mismatch.
using w and X.T gets type error the unsuported format string
using w T and X.T gets type error the unsuported format string

using X and w gets a type error the unsuported format string
using X.T and w gets a value error the a dimension mismatch.
using X.T and w.T gets a value error the a dimension mismatch.
using X and w.T gets ats a type error the unsuported format string

thanks

Please post a screen capture image showing your examples in action, not just a lot of text. It will be easier for me to investigate what you’re asking about.

w,x,b <class ‘numpy.ndarray’> <class ‘numpy.ndarray’> <class ‘float’>
w,x,b (2,) (100, 2) 0.0


ValueError Traceback (most recent call last)
in
4 initial_w = np.zeros(n)
5 initial_b = 0.
----> 6 cost = compute_cost(X_train, y_train, initial_w, initial_b)
7 print(‘Cost at initial w and b (zeros): {:.3f}’.format(cost))

in compute_cost(X, y, w, b, *argv)
20 print(‘w,x,b’,type(w),type(X),type(b))
21 print(‘w,x,b’,w.shape,X.shape,b)
—> 22 z=n …
23 f=si …
24 print(‘f’,f.shape,f)

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 100 is different from 2)

A screen capture image would be better, I don’t understand all those … and ?

I think I answered your question about np.matmul() already. You have the operands in the wrong order. If you have np.matmul(w,x) and get an error, then try np.matmul(x,w).

I got it to work. I was not summing both of the log terms correctly. Using X times w worked. Thank you.

i go the entire programming assignment to work. thank you.