无法迭代数据集(AttributeError:模块“numpy”没有属性“complex”。)

问题描述 投票:0回答:1

我正在使用:

windows
python version 3.10.0
datasets==2.21.0
numpy==1.24.4

我尝试迭代刚刚下载的数据集:

from datasets import load_dataset
dataset = load_dataset("jacktol/atc-dataset", download_mode='force_redownload')


dataset['train'][0]

并出现错误:

AttributeError: module 'numpy' has no attribute 'complex'.
`np.complex` was a deprecated alias for the builtin `complex`. To avoid this error in existing code, use `complex` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.complex128` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

我需要迭代哪些 numpy 和数据集?

python numpy dataset huggingface-datasets
1个回答
0
投票

该错误是由于

NumPy
中的 np.complex 别名被弃用(在
1.20
版本
NumPy
中)和删除(在
1.24
版本 NumPy
NumPy Doc 1.24
)。

要解决此问题,您可以尝试更新

datasets
库:

pip install --upgrade datasets

和/或降级

NumPy
至删除之前:

例如

pip install numpy==1.23.5
© www.soinside.com 2019 - 2024. All rights reserved.