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

**URL:** <https://discuss.huggingface.co/t/attributeerror-trainoutput-object-has-no-attribute-metrics-when-finetune-custom-dataset/2970>\
**Category:** 🤗Transformers\
**Created:** [December 26, 2020, 10:43am UTC](https://discuss.huggingface.co/t/attributeerror-trainoutput-object-has-no-attribute-metrics-when-finetune-custom-dataset/2970 "2020-12-26T10:43:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![good74152](https://avatars.discourse-cdn.com/v4/letter/g/fbc32d/32.png) [@good74152](https://discuss.huggingface.co/u/good74152)\
**Post date:** [December 26, 2020, 10:43am UTC](https://discuss.huggingface.co/t/attributeerror-trainoutput-object-has-no-attribute-metrics-when-finetune-custom-dataset/2970/1 "2020-12-26T10:43:05Z")

</div>

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](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](https://us1.discourse-cdn.com/hellohellohello/original/2X/5/56736ba052e6d09e103718f1d759531f4b83dc75.png)

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

---

<div class="post-metadata">

**Author:** ![valhalla](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/valhalla/32/4179_2.png) [@valhalla](https://discuss.huggingface.co/u/valhalla)\
**Post date:** [December 29, 2020, 6:50am UTC](https://discuss.huggingface.co/t/attributeerror-trainoutput-object-has-no-attribute-metrics-when-finetune-custom-dataset/2970/2 "2020-12-29T06:50:32Z")

</div>

Hi

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

---

<div class="post-metadata">

**Author:** ![good74152](https://avatars.discourse-cdn.com/v4/letter/g/fbc32d/32.png) [@good74152](https://discuss.huggingface.co/u/good74152)\
**Post date:** [December 29, 2020, 11:08am UTC](https://discuss.huggingface.co/t/attributeerror-trainoutput-object-has-no-attribute-metrics-when-finetune-custom-dataset/2970/3 "2020-12-29T11:08:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](https://discuss.huggingface.co/u/sgugger)\
**Post date:** [January 4, 2021, 1:04pm UTC](https://discuss.huggingface.co/t/attributeerror-trainoutput-object-has-no-attribute-metrics-when-finetune-custom-dataset/2970/4 "2021-01-04T13:04:44Z")

</div>

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.
