Skip to content

RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target' in call to _thnn_nll_loss_forward #19181

@14H034160212

Description

@14H034160212

System Info

Hi,

I got the following issue RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target' in call to _thnn_nll_loss_forward when I was finetuning the stsb by using a finetuned roberta. I use this code to finetune the stsb task.

image

Does anyone have idea to fix the bug? The label for stsb is float type, so the code is using regression to train the model.

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

  1. Download the finetuned roberta model from here. The finetuned roberta was finetuned on a sentence binary classification task. (The issue may caused by the first stage finetuning which I was using a binary classification task, but the downstream task stsb is a regression task.)
  2. Load the finetuned roberta model and use this code to finetune the stsb task and I got the above issue.

Expected behavior

Please give me any advice to solve the issue. Many Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions