Python numpy ValueError: operands could not be broadcast together with shapes
In numpy, I have two "arrays", X is (m,n) and y is a vector (n,1)
using
X*y
I am getting the error
ValueError: operands could not be broadcast together with shapes (97,2) (2,1)
When (97,2)x(2,1) is clearly a legal matrix operation and should give me a (97,1) vector
While getting error operands could not be broadcast together with shapes Use the below mentioned code to get rid of the error:-
import numpy
numpy.dot(numpy.ones([97, 2]), numpy.ones([2, 1])).shape
Note: operands could not be broadcast together exception means that the arrays have incompatible shapes.