pythonu8darts

When TCN is used for prediction(python), there is a valueerror: high is out of bounds for int32. I can't find out why


The database is darts and the code is GitHub- https://unit8co.github.io/darts/examples/06-TCN-examples.html Every example here is used on pychar with the following errors My environment is created by CONDA, and the virtual environment is Python 3.8

Error message

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

Solution

    1. Go to the file ...\site-packages\darts\utils\torch.py in your system

    2. Find the line MAX_TORCH_SEED_VALUE = (1 << 63) - 1 which should be around line 17

    3. Change it to MAX_TORCH_SEED_VALUE = (1 << 31) - 1 so that it fits into 32 bit int.

    After saving this change, code should run fine.

    (credit: https://github.com/unit8co/darts/issues/235#issue-737158114)