python - Is this a Numpy Bug? Numpy ValueError: Object is not aligned -
this question has answer here:
i tried following commands:
>>> = np.matrix([[1,2],[3,4]]) >>> matrix([[1, 2], [3, 4]]) >>> b = np.matrix([[0,1],[0,1]]) >>> b matrix([[0, 1], [0, 1]]) >>> np.dot(a,b) matrix([[0, 3], [0, 7]]) so far, fine. after made following changes, error:
>>> tmp1 = a[np.ix_([1,1,0])] >>> tmp2 = b[np.ix_([1,1,0])] >>> tmp1.shape (3, 2) >>> tmp2.shape (3, 2) >>> np.dot(tmp1,tmp2) traceback (most recent call last): file "<stdin>", line 1, in <module> valueerror: objects not aligned please me on i've ignored when doing above operations. want dot product of tmp1 .* tmp2 expect matlab:
matrix([[0, 4], [0, 4],[0, 2]])
thanks.
the dot product of 2 matrices of size (3,2) not valid. try transposing 1 of them
Comments
Post a Comment