Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).


## [unreleased.Bugfixes] - YYYY-MM-DD

### Added


### Changed


### Deprecated


### Removed


### Fixed



## [1.1.6] - 2021-01-26

### Changed
Expand Down
1 change: 1 addition & 0 deletions tests/checkpointing/test_legacy_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"1.1.3",
"1.1.4",
"1.1.5",
"1.1.6",
])
def test_resume_legacy_checkpoints(tmpdir, pl_version):
path_dir = os.path.join(LEGACY_CHECKPOINTS_PATH, pl_version)
Expand Down
15 changes: 7 additions & 8 deletions tests/models/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ def training_epoch_end(self, outputs):

def test_training_epoch_end_metrics_collection_on_override(tmpdir):
""" Test that batch end metrics are collected when training_epoch_end is overridden at the end of an epoch. """
num_epochs = 1

class LoggingCallback(pl.Callback):

def on_train_epoch_end(self, trainer, pl_module):
def on_train_epoch_start(self, trainer, pl_module):
self.len_outputs = 0

def on_train_epoch_end(self, trainer, pl_module, outputs):
Expand All @@ -110,7 +109,6 @@ def on_train_epoch_start(self):
self.num_train_batches = 0

def training_epoch_end(self, outputs): # Overridden
pass
return

def on_train_batch_end(self, outputs, batch, batch_idx, dataloader_idx):
Expand All @@ -129,19 +127,20 @@ def on_train_batch_end(self, outputs, batch, batch_idx, dataloader_idx):

callback = LoggingCallback()
trainer = Trainer(
max_epochs=num_epochs,
max_epochs=1,
default_root_dir=tmpdir,
overfit_batches=2,
callbacks=[callback],
)

result = trainer.fit(overridden_model)
trainer.fit(overridden_model)
# outputs from on_train_batch_end should be accessible in on_train_epoch_end hook
# if training_epoch_end is overridden
assert callback.len_outputs == overridden_model.num_train_batches
# outputs from on_train_batch_end should be accessible in on_train_epoch_end hook if training_epoch_end is overridden

result = trainer.fit(not_overridden_model)
assert callback.len_outputs == 0
trainer.fit(not_overridden_model)
# outputs from on_train_batch_end should be empty
assert callback.len_outputs == 0


@pytest.mark.skipif(not torch.cuda.is_available(), reason="test requires GPU machine")
Expand Down