Skip to content

Commit

Permalink
Implemented updating callback metric only if key not exists (less aff…
Browse files Browse the repository at this point in the history
…ecting other users code).

Moved CHANGELOG.md entry to unreleased section.
  • Loading branch information
olineumann committed Jun 11, 2020
1 parent 757abca commit 1c6bfaa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed

- Fixed callback metric getting overwritten by progress bar or log metric ([#1800](https://github.com/PyTorchLightning/pytorch-lightning/pull/1800))

## [0.8.0] - 2020-06-DD

Expand Down Expand Up @@ -70,7 +71,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed an issue with `_auto_collect_arguments` collecting local variables that are not constructor arguments and not working for signatures that have the instance not named `self` ([#2048](https://github.com/PyTorchLightning/pytorch-lightning/pull/2048))
- Fixed mistake in parameters' grad norm tracking ([#2012](https://github.com/PyTorchLightning/pytorch-lightning/pull/2012))
- Fixed CPU and hanging GPU crash ([#2118](https://github.com/PyTorchLightning/pytorch-lightning/pull/2118))
- Fixed callback metric getting overwritten by progress bar or log metric ([#1800](https://github.com/PyTorchLightning/pytorch-lightning/pull/1800))

## [0.7.6] - 2020-05-16

Expand Down
13 changes: 13 additions & 0 deletions pytorch_lightning/trainer/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ def process_output(self, output, train=False):
# ---------------
hiddens = output.get('hiddens')

# iterate over log_metric and progress_bar metric values
# and add it to the callback metric dict because every
# metric value of logging or progressbar could be a candidate
# for early stopping or similar
#
# NOTE: through the dict looping sequence a priority is defined
# so first log metrics values will be added if not existing and
# then progress bar values if not existing in callback and log metric
for metric_dict in [log_metrics, progress_bar_metrics]:
for key in metric_dict.keys():
if key not in callback_metrics.keys():
callback_metrics[key] = metric_dict[key]

# detach all metrics for callbacks to prevent memory leaks
# no .item() because it will slow things down
callback_metrics = recursive_detach(callback_metrics)
Expand Down

0 comments on commit 1c6bfaa

Please sign in to comment.