fix(wandb): use same logger on multiple training loops (#2055)

* 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
This commit is contained in:
Boris Dayma
2020-06-02 18:46:02 -04:00
committed by GitHub
parent 0914873bc2
commit 00f1ac11e6
3 changed files with 5 additions and 3 deletions
+2
View File
@@ -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
+1 -1
View File
@@ -128,7 +128,7 @@ class WandbLogger(LightningLoggerBase):
@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:
+2 -2
View File
@@ -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)