Reputation: 45
thetaU = np.linalg.inv(np.linalg.inv(theta) + theta2_input**(-1)*np.transpose(X_test[i]) * X_test[i])
When I execute the following inside one of my functions.. I get the following error:
ValueError: operands could not be broadcast together with shapes (2,100) (100,2)
I'm kind of new to Python and would appreciate any help. Thank you.
Upvotes: 2
Views: 1598
Reputation: 57033
In NumPy, operator *
does not represent matrix multiplication. It multiplies two arrays element-wise. Replace it with np.matmul()
or np.dot()
:
np.matmul(np.transpose(X_test[i]), X_test[i]))
Upvotes: 2