-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix global step increment on training_epoch_end (#3673)
* fix * fix global step err * fix global step err * fix global step err * fix global step err * fix global step err * fix global step err Co-authored-by: William Falcon <waf2107@columbia.edu>
- Loading branch information
1 parent
d15fd75
commit f37e9e8
Showing
5 changed files
with
90 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Tests to ensure that the training loop works with a dict | ||
""" | ||
from pytorch_lightning import Trainer | ||
from tests.base.model_template import EvalModelTemplate | ||
import os | ||
|
||
|
||
def test_training_step_scalar(tmpdir): | ||
""" | ||
Tests that only training_step can be used | ||
""" | ||
os.environ['PL_DEV_DEBUG'] = '1' | ||
|
||
model = EvalModelTemplate() | ||
model.validation_step = None | ||
model.test_step = None | ||
model.training_step = model.training_step_result_obj_dp | ||
model.training_step_end = None | ||
model.training_epoch_end = None | ||
model.validation_step = model.validation_step_result_obj_dp | ||
model.validation_step_end = None | ||
model.validation_epoch_end = None | ||
model.test_dataloader = None | ||
|
||
trainer = Trainer( | ||
default_root_dir=tmpdir, | ||
limit_train_batches=2, | ||
limit_val_batches=2, | ||
max_epochs=2, | ||
row_log_interval=1, | ||
weights_summary=None, | ||
) | ||
trainer.fit(model) | ||
|
||
# epoch 0 | ||
assert trainer.dev_debugger.logged_metrics[0]['global_step'] == 0 | ||
assert trainer.dev_debugger.logged_metrics[1]['global_step'] == 1 | ||
assert trainer.dev_debugger.logged_metrics[2]['global_step'] == 1 | ||
|
||
# epoch 1 | ||
assert trainer.dev_debugger.logged_metrics[3]['global_step'] == 2 | ||
assert trainer.dev_debugger.logged_metrics[4]['global_step'] == 3 | ||
assert trainer.dev_debugger.logged_metrics[5]['global_step'] == 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters