# Difference between calling model() and using Trainer()?

**URL:** <https://discuss.huggingface.co/t/difference-between-calling-model-and-using-trainer/1696>\
**Category:** Beginners\
**Created:** [October 22, 2020, 2:55pm UTC](https://discuss.huggingface.co/t/difference-between-calling-model-and-using-trainer/1696 "2020-10-22T14:55:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![BramVanroy](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bramvanroy/32/47360_2.png) [@BramVanroy](https://discuss.huggingface.co/u/BramVanroy)\
**Post date:** [October 22, 2020, 9:34pm UTC](https://discuss.huggingface.co/t/difference-between-calling-model-and-using-trainer/1696/2 "2020-10-22T21:34:11Z")

</div>

This might be related, as it discusses a recently fixed bug with a Colan notebook.

> [@Using hyperparameter-search in Trainer](https://discuss.huggingface.co/t/using-hyperparameter-search-in-trainer/785/25):
>
> Hi @sgugger, in case you’re not aware of it, it seems the latest commit on [master](https://github.com/huggingface/transformers/commit/e174bfeb340d3d3468d9c8eebce95c42aa2dcf84) broke the [Colab notebook](https://twitter.com/GuggerSylvain/status/1318215507242291202) you shared on Twitter Trying to run that notebook, I hit the following error when trying to run best\_run = trainer.hyperparameter\_search(n\_trials=10, direction="maximize") with the optuna backend. Stack trace: /usr/local/lib/python3.6/dist-packages/sklearn/metrics/\_classification.py:900: RuntimeWarning: invalid value encountered in double\_scalars [W 2020-10-22 14:58:41,815] Trial 0 f…

But to answer your question concerning the results: the results when using the Trainer or your own trainer should be the same as long as you use the same loss function and hyperparameters.

---

_[View the full topic](https://discuss.huggingface.co/t/difference-between-calling-model-and-using-trainer/1696)._
