facebookresearch / InferSent

InferSent sentence embeddings
Other
2.28k stars 470 forks source link

run train_nli.py #69

Closed congruili closed 6 years ago

congruili commented 6 years ago

Anyone knows what's wrong? Why the dimension of the loss tensor is 0? Thanks!

train_nli.py:187: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
  all_costs.append(loss.data[0])
Traceback (most recent call last):
  File "train_nli.py", line 291, in <module>
    train_acc = trainepoch(epoch)
  File "train_nli.py", line 218, in trainepoch
    round(100.*correct/(stidx+k), 2)))
TypeError: type Tensor doesn't define __round__ method
congruili commented 6 years ago

The issue was caused pytorch 0.4.0, using pytorch 0.3.1 would work.

dougc333 commented 5 years ago

you can also change correct to correct.item()

guotong1988 commented 5 years ago

This project do not support training anymore. So do you know a better code for sentence embedding? Thank you!

Punchwes commented 4 years ago

changed to item() but loss not updated anymore..... anyone has any solution..