I have a sparse matrix W, when I use linalg.pinv(W)
, it throws some errors:
Traceback (most recent call last):
File "/Users/ad9075/PycharmProjects/bednmf/test.py", line 14, in testNmfRun
self.factor = factorization(self.V)
File "/Users/ad9075/PycharmProjects/bednmf/nmf.py", line 18, in factorization
W_trans = linalg.pinv(W)
File "/Library/Python/2.7/site-packages/scipy/linalg/basic.py", line 540, in pinv
b = np.identity(a.shape[0], dtype=a.dtype)
IndexError: tuple index out of range`
But when I modify it to linalg.pinv(W.todense())
, it works well. However, do I really need to convert the sparse matrix if I want to calculate the generaized inverse? Does anyone have ideas about this?
Thanks!