【问题标题】:How to change numpy's intc value from 32 to 64 bit如何将 numpy 的 intc 值从 32 位更改为 64 位
【发布时间】:2015-03-05 06:57:21
【问题描述】:

我遇到了 numpy 的 intc 数据类型的问题。我在我的机器上运行 Linux 64 位。我需要实例化一个索引超过 32 位限制的 scipy.sparse.csr_matrix。例如:

我已经实例化了一个这样的 csr 矩阵:

matrix=csr_matrix((2, 4132009369),dtype=int8)

这对我没有任何问题。然后,在我做的代码的某处,让我们说:

matrix[0, 2401803431]=1

我得到了ValueError: column index values must be >= 0。我调试了代码,发现在 scipy 的 csr_matrix 实现中的某处,列值被转换为 numpy 的 intc 数据类型。 为了确保这是一个 intc 问题,我检查了以下代码:

>>> import numpy as np
>>> info=np.iinfo(np.intc)
>>> info.max
2147483647

该值为 2^31-1。 那么,如果有办法从 32 位 intc 到 64 位 intc,您有什么建议吗?在这个页面http://docs.scipy.org/doc/numpy/user/basics.types.html 它说

intc    Identical to C int (normally int32 or int64)

非常感谢您的宝贵时间!

【问题讨论】:

    标签: python numpy 32bit-64bit sparse-matrix type-conversion


    【解决方案1】:

    我通过将 scipy 库升级到最新版本来解决(以前我有 1.3,现在是 1.4)

    【讨论】:

    • 我想你的意思是你从 0.13 升级到了 0.14。
    猜你喜欢
    • 1970-01-01
    • 2015-02-22
    • 1970-01-01
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    • 2013-01-11
    相关资源
    最近更新 更多