Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jnuvenus opened this issue Nov 27, 2018 · 1 comment

Comments

@jnuvenus
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants