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

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdifference-between-calling-model-and-using-trainer%2F1696%3E%5C
**Category:** Beginners\
**Created:** [October 22, 2020, 2:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdifference-between-calling-model-and-using-trainer%2F1696 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FBramVanroy)%5C
**Post date:** [October 22, 2020, 9:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdifference-between-calling-model-and-using-trainer%2F1696%2F2 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-hyperparameter-search-in-trainer%2F785%2F25)%3A
>
> 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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdifference-between-calling-model-and-using-trainer%2F1696)._
