Improving Performance of Multiplication of Scipy Sparse Matrices

后端 未结 2 1289
孤城傲影
孤城傲影 2021-02-03 10:44

Given a Scipy CSC Sparse matrix \"sm\" with dimensions (170k x 170k) with 440 million non-null points and a sparse CSC vector \"v\" (170k x 1) with a few non-null points, is the

2条回答
  •  旧巷少年郎
    2021-02-03 11:39

    Recently i had the same issue. I solved it like this.

    def sparse_col_vec_dot(csc_mat, csc_vec):
        curr_mat = csc_mat.tocsr()
        ret curr_mat* csc_vec
    

    The trick here is we have to make one version of the matrix as row representation and the other version as column representation.

提交回复
热议问题