Skip to content
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

Merged
merged 2 commits into from
Aug 25, 2020
Merged

More tests to Trainer #6699

merged 2 commits into from
Aug 25, 2020

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Aug 24, 2020

While doing see, realized there were some problems with the seed (in particular for HP search) so added a few tests of that too.

@@ -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
Copy link
Collaborator Author

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."
Copy link
Collaborator Author

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."
Copy link
Collaborator Author

@sgugger sgugger Aug 24, 2020

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
Copy link

codecov bot commented Aug 24, 2020

Codecov Report

Merging #6699 into master will decrease coverage by 0.42%.
The diff coverage is 70.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/transformers/trainer.py 53.64% <70.00%> (+2.91%) ⬆️
src/transformers/modeling_tf_electra.py 25.13% <0.00%> (-73.83%) ⬇️
src/transformers/modeling_tf_t5.py 26.84% <0.00%> (-64.10%) ⬇️
src/transformers/modeling_t5.py 71.61% <0.00%> (-12.22%) ⬇️
src/transformers/configuration_t5.py 85.71% <0.00%> (-10.72%) ⬇️
src/transformers/generation_tf_utils.py 83.70% <0.00%> (-2.76%) ⬇️
src/transformers/modeling_tf_utils.py 84.69% <0.00%> (-1.96%) ⬇️
src/transformers/modeling_utils.py 87.50% <0.00%> (-0.56%) ⬇️
src/transformers/file_utils.py 82.66% <0.00%> (+0.50%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b4c617...f7790fa. Read the comment docs.

Copy link
Member

@LysandreJik LysandreJik left a 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!

Comment on lines +213 to +214
# Seed must be set before instantiating the model when using model
set_seed(self.args.seed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@sgugger sgugger merged commit abc0202 into master Aug 25, 2020
@sgugger sgugger deleted the test_trainer branch August 25, 2020 11:07
Zigur pushed a commit to Zigur/transformers that referenced this pull request Oct 26, 2020
* More tests to Trainer

* Add warning in the doc
fabiocapsouza pushed a commit to fabiocapsouza/transformers that referenced this pull request Nov 15, 2020
* More tests to Trainer

* Add warning in the doc
fabiocapsouza added a commit to fabiocapsouza/transformers that referenced this pull request Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants