Skip to content

Commit

Permalink
fix(wandb): use same logger on multiple training loops (#2055)
Browse files Browse the repository at this point in the history
* fix(wandb): use same logger on multiple training loops

New training loops reset step to 0 which would previously try to overwrite logs

fix #2015

* docs(changelog.md): add reference to PR 2055
  • Loading branch information
borisdayma authored and justusschock committed Jun 29, 2020
1 parent 55f2713 commit 9825768
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

- Fixed `save_weights_only` in ModelCheckpoint ([#1780](https://github.com/PyTorchLightning/pytorch-lightning/pull/1780))

- Allow use of same `WandbLogger` instance for multiple training loops ([#2055](https://github.com/PyTorchLightning/pytorch-lightning/pull/2055))

## [0.7.6] - 2020-05-16

### Added
Expand Down
2 changes: 1 addition & 1 deletion pytorch_lightning/loggers/wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None:

@rank_zero_only
def log_metrics(self, metrics: Dict[str, float], step: Optional[int] = None) -> None:
self.experiment.log(metrics, step=step)
self.experiment.log({'global_step': step, **metrics} if step is not None else metrics)

@property
def name(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions tests/loggers/test_wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def test_wandb_logger(wandb):
logger = WandbLogger(anonymous=True, offline=True)

logger.log_metrics({'acc': 1.0})
wandb.init().log.assert_called_once_with({'acc': 1.0}, step=None)
wandb.init().log.assert_called_once_with({'acc': 1.0})

wandb.init().log.reset_mock()
logger.log_metrics({'acc': 1.0}, step=3)
wandb.init().log.assert_called_once_with({'acc': 1.0}, step=3)
wandb.init().log.assert_called_once_with({'global_step': 3, 'acc': 1.0})

logger.log_hyperparams({'test': None})
wandb.init().config.update.assert_called_once_with({'test': None}, allow_val_change=True)
Expand Down

0 comments on commit 9825768

Please sign in to comment.