小编Ant*_*vic的帖子

Scipy稀疏矩阵乘法

我有使用numpy数组的矩阵乘法矩阵示例:

import numpy as np
m = np.array([[1,2,3],[4,5,6],[7,8,9]])
c = np.array([0,1,2])
m * c
array([[ 0,  2,  6],
       [ 0,  5, 12],
       [ 0,  8, 18]])
Run Code Online (Sandbox Code Playgroud)

如果m是scipy稀疏CSR矩阵,我怎么能做同样的事情?这会导致尺寸不匹配:

sp.sparse.csr_matrix(m)*sp.sparse.csr_matrix(c)
Run Code Online (Sandbox Code Playgroud)

python numpy matrix scipy sparse-matrix

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

matrix ×1

numpy ×1

python ×1

scipy ×1

sparse-matrix ×1