andregraubner / ClimateNet

Climate Analytics using Deep Neural Networks in Python.
https://www.nersc.gov/research-and-development/data-analytics/big-data-center/climatenet/
MIT License
59 stars 25 forks source link

Fix the same device issue #22

Open Anshita1Saxena opened 1 year ago

Anshita1Saxena commented 1 year ago

Hi Authors,

I fixed this issue RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu) in file utils/losses.py. Please review it and merge it.

Stacktrace:

Epoch 1:
^M  0%|          | 0/396 [00:00<?, ?it/s]^M  0%|          | 0/396 [00:29<?, ?it/s]
Traceback (most recent call last):
  File "/project/60025/anshita/ClimateNet/example.py", line 20, in <module>
    cgnet.train(train)
  File "/project/60025/anshita/ClimateNet/climatenet/models.py", line 90, in train
    loss = jaccard_loss(outputs, labels)
  File "/project/60025/anshita/ClimateNet/climatenet/utils/losses.py", line 21, in jaccard_loss
    true_1_hot = torch.eye(num_classes)[true.squeeze(1)]
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

Thank You.

Best regards, Anshita Saxena