当TCN用于预测(python)时,有一个valueerror:high超出int32的界限。我不知道为什么

2024-04-23 08:08:24 发布

您现在位置:Python中文网/ 问答频道 /正文

数据库是darts,代码是GitHub-https://unit8co.github.io/darts/examples/06-TCN-examples.html 这里的每个示例都在pychar上使用,但有以下错误 我的环境是由CONDA创建的,虚拟环境是Python 3.8

错误消息

Traceback (most recent call last):
  File "D:/pycharm/testtcn/energy.py", line 33, in <module>
    model_en = TCNModel(
  File "D:\anconda\envs\env_name\lib\site-packages\darts\utils\torch.py", line 64, in decorator
    manual_seed(self._random_instance.randint(0, high=MAX_TORCH_SEED_VALUE))
  File "mtrand.pyx", line 745, in numpy.random.mtrand.RandomState.randint
  File "_bounded_integers.pyx", line 1343, in numpy.random._bounded_integers._rand_int32
ValueError: high is out of bounds for int32

Tags: integersinpynumpy错误linerandomexamples
1条回答
网友
1楼 · 发布于 2024-04-23 08:08:24
  1. 转到系统中的文件...\site-packages\darts\utils\torch.py

  2. 找到第17行附近的MAX_TORCH_SEED_VALUE = (1 << 63) - 1

  3. 将其更改为MAX_TORCH_SEED_VALUE = (1 << 31) - 1,以便适合32位int

保存此更改后,代码应该可以正常运行

(信用证:https://github.com/unit8co/darts/issues/235#issue-737158114

相关问题 更多 >