Scipy sparse matrices element wise multiplication

梦想的初衷 提交于 2019-12-05 18:15:10

I suspect that your sparse matrices are becoming non sparse when you perform the operation have you tried just:

A.multiply(B)

As I suspect that it will be better optimised than anything that you can easily do.

If A is not already the correct type of sparse matrix you might need:

A = A.tocsr()
# May also need 
# B = B.tocsr()
A = A.multiply(B)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!