Skip to content

Commit 00f1ac1

Browse files
authored
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
1 parent 0914873 commit 00f1ac1

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
6666

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

69+
- Allow use of same `WandbLogger` instance for multiple training loops ([#2055](https://github.com/PyTorchLightning/pytorch-lightning/pull/2055))
70+
6971
## [0.7.6] - 2020-05-16
7072

7173
### Added

pytorch_lightning/loggers/wandb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None:
128128

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

133133
@property
134134
def name(self) -> str:

tests/loggers/test_wandb.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def test_wandb_logger(wandb):
1313
logger = WandbLogger(anonymous=True, offline=True)
1414

1515
logger.log_metrics({'acc': 1.0})
16-
wandb.init().log.assert_called_once_with({'acc': 1.0}, step=None)
16+
wandb.init().log.assert_called_once_with({'acc': 1.0})
1717

1818
wandb.init().log.reset_mock()
1919
logger.log_metrics({'acc': 1.0}, step=3)
20-
wandb.init().log.assert_called_once_with({'acc': 1.0}, step=3)
20+
wandb.init().log.assert_called_once_with({'global_step': 3, 'acc': 1.0})
2121

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

0 commit comments

Comments
 (0)