Difference between calling model() and using Trainer()?
Hi All,I was wondering if there is any tangible difference between callingmodel()and feeding data in manually, or using theTrainer()object?If I run a program to batch my data and feed it manually, will the training results be the same as usingTrainer()?I only ask because I am getting some errors while applying the language modelling protocol (from:https://colab.research.google.com/github/huggingface/blog/blob/master/notebooks/01_how_to_train.ipynb#scrollTo=YZ9HSQxAAbme) with theTrainer()module but manually seems to work fine.
2020-10-22T21:34:11Z
This might be related, as it discusses a recently fixed bug with a Colan notebook.Using hyperparameter-search in Trainer🤗TransformersHi@sgugger, in case you’re not aware of it, it seems the latest commit onmasterbroke theColab notebookyou 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.
2020-10-23T13:09:37Z
Trainer is mostly there to take the boilerplate out of your way, especially for mixed-precision training, distributed training and TPU training, but it only does the training loop (with good hyperparameter defaults) so it should match your manual training loop.
2020-10-23T16:00:31Z
Wonderful, thanks for the clarification!
2020-10-23T16:04:03Z
I was dealing with a different error:RuntimeError: element 0 of tensors does not require grad and does not have a grad_fnI will look into it!
2020-11-18T12:20:00Z
Did you find out what was wrong?I’m running into the same kind of error with theTrainerobject
2020-11-19T00:38:05Z
Unfortunately I never got it to work with the Transformer-XL implementation I was working on, but I modified BERT to fit my application and it works with that instead