TideDancer / interspeech21_emotion

94 stars 19 forks source link

NameError: name 'h' is not defined #3

Closed Gpwner closed 3 years ago

Gpwner commented 3 years ago

I am trying to run the run.sh ,But I got an error:

  File "/home/*/PycharmProjects/interspeech21_emotion/model.py", line 97, in forward
    loss_cls = self._cls_loss(logits_cls, labels[1])
  File "/home/*/PycharmProjects/interspeech21_emotion/model.py", line 62, in _cls_loss
    loss = F.cross_entropy(logits, cls_labels.to(h.device))
NameError: name 'h' is not defined

it seem to be h is not define in this line https://github.com/TideDancer/interspeech21_emotion/blob/main/model.py#L62

Any help?Thanks in advance~

Gpwner commented 3 years ago

It seem to be

 loss = F.cross_entropy(logits, cls_labels.to('cuda'))

If I am right ,lee me know.

TideDancer commented 3 years ago

Yes you are right, if using cuda. Otherwise it should be logits.device, not h.device. I have just corrected and updated. Thanks for letting me know!