ThilinaRajapakse / pytorch-transformers-classification

Based on the Pytorch-Transformers library by HuggingFace. To be used as a starting point for employing Transformer models in text classification tasks. Contains code to easily train BERT, XLNet, RoBERTa, and XLM models for text classification.
Apache License 2.0
306 stars 97 forks source link

utils.py [output_mode = regression] #34

Open vr25 opened 5 years ago

vr25 commented 5 years ago

Hi,

I am trying to predict a score (float) using regression and I was wondering what changes need to be made in lines 254 and 258 in utils.py

Thanks!

vr25 commented 5 years ago

Also, since it uses BinaryClassificationProcessor, it creates the logits tensor with size of [10,2] (say, my input file has 10 texts). After view(-1), logits becomes size=20 but the labels are still size=10. Hence, MSELoss() returns the following size mismatch error:

image

Thanks!

ThilinaRajapakse commented 5 years ago

Set this in the args dict.

'output_mode': 'regression'

vr25 commented 5 years ago

On setting: 'output_mode': 'regression' it still gives the following error:

image