我有一个稀疏矩阵 W,当我使用 时linalg.pinv(W)
,它会引发一些错误:
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`
但是当我将其修改为 时linalg.pinv(W.todense())
,它运行良好。但是,如果我想计算生成的逆矩阵,我真的需要转换稀疏矩阵吗?有人对此有想法吗?
谢谢!