【发布时间】:2014-02-16 17:39:38
【问题描述】:
矩阵中行和列的点积是 1x1 csr_matrix。如何有效地将其转换为标量?现在我使用sum。 M下面是方阵:
dot_product_result = csr_matrix.sum(M.getrow(3).dot(M.getcol(5)))
Here's the lil_matrix documentation.
更新当我尝试以下解决方案时,我收到此错误:
raise NotImplementedError('adding a nonzero scalar to a '
NotImplementedError: adding a nonzero scalar to a sparse matrix is not supported
这是我正在使用的实际代码:
e = rating - Q.getrow(mid).dot(P.getcol(uid))[0]
iteration_error += e
我将iteration_error 初始化为 0.0。
【问题讨论】:
标签: python matrix scipy sparse-matrix