python - dot routine for scipy.sparse matrices produces error -
i have csr matrix : >> print type(tfidf) <class 'scipy.sparse.csr.csr_matrix'> i want take dot product of 2 rows of csr matrix : >> v1 = tfidf.getrow(1) >> v2 = tfidf.getrow(2) >> print type(v1) <class 'scipy.sparse.csr.csr_matrix'> both v1 , v2 csr matrices. use dot subroutine: >> print v1.dot(v2) traceback (most recent call last): file "cosine.py", line 10, in <module> print v1.dot(v2) file "/usr/lib/python2.7/dist-packages/scipy/sparse/base.py", line 211, in dot return self * other file "/usr/lib/python2.7/dist-packages/scipy/sparse/base.py", line 246, in __mul__ raise valueerror('dimension mismatch') valueerror: dimension mismatch they rows of same matrix, dimentions ought match: >> print v1.shape (1, 4507) >> print v2.shape (1, 4507) why dot subroutine not work? thanks. to perform dot product of 2 row vectors, have