AttributeError: 'TrainOutput' object has no attribute 'metrics' when finetune custom dataset

Hi,
I’m try to finetune Bert on sst2 dataset by using run_glue.py (https://github.com/huggingface/transformers/blob/master/examples/text-classification/run_glue.py).
I randomly pick 1% train data and 10 validation data from sst2 original dataset, and build them as csv. file with label and sentence columns.

Here is my finetune setting:
image

But there is an error occurred:
Traceback (most recent call last):
File “run_glue.py”, line 432, in
main()
File “run_glue.py”, line 356, in main
metrics = train_result.metrics
AttributeError: ‘TrainOutput’ object has no attribute ‘metrics’

I run all these scripts on colab pro

Hi

Could you post your transformers version. Also to run the examples you should install transformers from source.

Thanks for your reply!!
My transformers is the newest version 4.1.1.
And I think I figure out why the error occured, because my label column index is 0 and sentence column is 1, the default setting is that the label column index should be 1 and sentence column index should be 0.

The newest version can not be enough, you need a source install. In this case, the metrics have been added to the TrainiOutput very recently.