Scipy 稀疏矩阵中的寻址范围
我有一个大矩阵,目前在 numpy 中,我想将其移植到 scipy 稀疏矩阵,因为保存 numpy (2000,2000) 矩阵的文本表示超过 100mb。
(1) scipy 中似乎有太多可用的稀疏矩阵 [例如, lil_matrix 或 dok_matrix< /a>- 哪一个对于简单递增来说是最佳的,并且可以有效地保存到数据库?
(2) 我希望能够像这样解决矩阵中的范围:
>> import numpy as np
>> a = np.zeros((1000,1000))
>> a[3:5,4:7] += 1
似乎这对于稀疏矩阵来说是不可能的?
I have a large matrix, currently in numpy that i would like to port over to scipy sparse matrix, because saving the text representations of the numpy (2000,2000) matrix is over 100mb.
(1) There seem to a surfeit of sparse matrices available in scipy [for instance, lil_matrix or dok_matrix- which one would be optimal for simple incrementing, and efficient to save to a database?
(2)
I'd like to be able to address ranges in the matrix like so:
>> import numpy as np
>> a = np.zeros((1000,1000))
>> a[3:5,4:7] += 1
It seems that this is not possible for the sparse matrices?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不能说哪个存储效率最高。这将取决于您的数据。
不过,我可以说
+=
运算符是有效的,只是您不能依赖通常的数组广播规则:I can't say which is most efficient to store. It's going to depend on your data.
I can say, however that the
+=
operator works, just that you can't rely on the usual array broadcasting rules: