laiguokun / LSTNet

MIT License
638 stars 171 forks source link

Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #2 'other' #6

Open jnuvenus opened 5 years ago

jnuvenus commented 5 years ago

Hello, When I run LSTNet 'python main.py --gpu 0 --horizon 24 --data data/electricity.txt --save save/elec.pt --output_fun Linear' return error as follows.

Traceback (most recent call last): File "main.py", line 150, in val_loss, val_rae, val_corr = evaluate(Data, Data.valid[0], Data.valid[1], model, evaluateL2, evaluateL1, args.batch_size); File "main.py", line 36, in evaluate rae = (total_loss_l1/n_samples)/data.rae RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #2 'other'

Have you ever had a similar error? How to solve this problem?

BernardOng commented 5 years ago

I had this same exact issue and was able to resolve it by correcting all the UserWarnings on the tensor.item() suggested corrections.

On main.py, lines 60, 32, and 33, Need to convert all the data[0] to item() example: whatevertensor.data[0] change to --> whatevertensor.item()

After I edited that, the whole thing ran fine. My GPU kicked in and the training was completed.