RuntimeError: invalid argument 2: non-empty vector or matrix expected at /opt/conda/conda-bld/pytorch_1550780889552/work/aten/src/THCUNN/generic/

Experts, What’s the reason for that?

Could you check the input shapes of all tensors that you are passing to your criterion?
Apparently some of them are empty. However, the error seems to point to the weight argument.
Are you using weighted cross entropy or are you passing the weight manually to the loss calculation?

Hi Patrick, Im using transformers to finetune an input sequence of dialogues. I get the same error, but how would I check the input shapes of the tensors ?

You could print the shapes via:

output = model(input)
loss = criterion(output, target)

If you are seeing the same error message, the target tensor might be empty.
Feel free to post your training code, so that we can have a look, if you get stuck.