将1x1稀疏矩阵转换为s

2024-09-28 21:51:45 发布

您现在位置:Python中文网/ 问答频道 /正文

矩阵中行和列的点积是1x1csr_matrix。如何有效地将其转换为标量?现在我使用sumM下面是一个方阵:

dot_product_result = csr_matrix.sum(M.getrow(3).dot(M.getcol(5)))

Here's the ^{} documentation.

更新当我尝试下面的解决方案时,我得到以下错误:

^{pr2}$

这是我实际使用的代码:

 e = rating - Q.getrow(mid).dot(P.getcol(uid))[0]
 iteration_error += e

我将iteration_error初始化为0.0。在


Tags: thehere矩阵errorresultproductmatrixdot