python - Numpy matrix multiplication error -


i have 2 big matrices:

       xn = np.matrix(x)        xnt = xn.transpose() 

then xn this:

   >>> xn    matrix([['0,208', '0,22', '0,208', ..., '0,194', '0,205', '0,205'],     ['0,22', '0,208', '0,214', ..., '0,205', '0,205', '0,214'],     ['0,208', '0,214', '0,22', ..., '0,205', '0,214', '0,211'],     ...,      ['0,214', '0,214', '0,208', ..., '0,199', '0,211', '0,226'],     ['0,214', '0,208', '0,208', ..., '0,211', '0,226', '0,252'],     ['0,208', '0,208', '0,211', ..., '0,226', '0,252', '0,24']],     dtype='|s5') 

but want multiply xn , xnt. error occurs.

  >>> print(xn*xnt)      traceback (most recent call last):     file "<pyshell#2>", line 1, in <module>     print(xn*xnt)     file "c:\python27\lib\site-packages\numpy\matrixlib\defmatrix.py", line 330, in __mul__     return n.dot(self, asmatrix(other))     valueerror: data type must provide itemsize 

what's problem?

your matrix elements strings - note dtype='|s5' when print matrix. try converting elements of x strings floats first.


Comments