Skip to content

Commit 0dd6d3a

Browse files
authored
Avoid adding None loss values in training_epoch_end (#7772)
1 parent 7e6010f commit 0dd6d3a

File tree

3 files changed

+62
-237
lines changed

3 files changed

+62
-237
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
161161
- Fixed `ProgressBar` pickling after calling `trainer.predict` ([#7608](https://github.com/PyTorchLightning/pytorch-lightning/pull/7608))
162162

163163

164+
- Fixed `None` loss keys getting added in `training_epoch_end` when using manual optimization and not returning a loss ([#7772](https://github.com/PyTorchLightning/pytorch-lightning/pull/7772))
165+
166+
164167
- Fixed print errors in `ProgressBar` when `trainer.fit` is not called ([#7674](https://github.com/PyTorchLightning/pytorch-lightning/pull/7674))
165168

166169

pytorch_lightning/trainer/training_loop.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ def _prepare_outputs(
390390

391391
for tbptt_output in batch_outputs:
392392
out = tbptt_output.extra
393-
out['loss'] = tbptt_output.minimize
393+
if tbptt_output.minimize is not None:
394+
out['loss'] = tbptt_output.minimize.detach()
394395
processed_tbptt_outputs.append(out)
395396

396397
# if there was only one tbptt step then we can collapse that dimension

0 commit comments

Comments
 (0)