-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More tests to Trainer #6699
More tests to Trainer #6699
Conversation
@@ -77,6 +77,7 @@ jobs: | |||
- v0.3-torch_and_tf-{{ checksum "setup.py" }} | |||
- v0.3-{{ checksum "setup.py" }} | |||
- run: pip install --upgrade pip | |||
- run: pip install git+https://github.com/huggingface/nlp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, using nlp master branch to test the integration with Trainer (we need some unreleased features). Not sure if we want to keep it this way for the foreseeable future or use the last release later on.
self.data_collator = data_collator if data_collator is not None else default_data_collator | ||
self.train_dataset = train_dataset | ||
self.eval_dataset = eval_dataset | ||
self.model_init = model_init | ||
self.compute_metrics = compute_metrics | ||
self.optimizer, self.lr_scheduler = optimizers | ||
if model_init is not None and (self.optimizer is not None or self.lr_scheduler is not None): | ||
raise RuntimeError( | ||
"Passing a `model_init` is incompatible with providing the `optimizers` argument." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raising an error as a defense mechanism: model_init
means each new training starts from scratch, thus needs a clean optimizer/scheduler.
) | ||
self.hp_search_backend = backend | ||
|
||
if self.model_init is None: | ||
raise RuntimeError( | ||
"To use hyperparameter search, you need to pass your model through a model_init function." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defense mechanism: you can't use HP search if the model is not reinitialized at each training.
Codecov Report
@@ Coverage Diff @@
## master #6699 +/- ##
==========================================
- Coverage 79.44% 79.01% -0.43%
==========================================
Files 156 156
Lines 28386 28388 +2
==========================================
- Hits 22551 22432 -119
- Misses 5835 5956 +121
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, love the tests!
# Seed must be set before instantiating the model when using model | ||
set_seed(self.args.seed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
* More tests to Trainer * Add warning in the doc
* More tests to Trainer * Add warning in the doc
This reverts commit 28e8214.
While doing see, realized there were some problems with the seed (in particular for HP search) so added a few tests of that too.