mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-09 11:32:07 +08:00
wandb logger 'global_step' affects other logger (#1492)
* Removed unnecessary 'global_step' from wandb logger. * Fixed wrong step implementation in wandb and missing metric skipping in logger base. * simplified metric check in base logger * Added Fix Description in CHANGELOG.md * Updated wandb logger tests. * udpate test, step=3 * Moved Fix Description in CHANGELOG.md to unreleased. * Update CHANGELOG.md Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
This commit is contained in:
co-authored by
Adrian Wälchli
Jirka Borovec
parent
4dc77b5a1a
commit
152a2eb30c
@@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
- Fixed Horovod distributed backend to set the `root_gpu` property ([#1669](https://github.com/PyTorchLightning/pytorch-lightning/pull/1669))
|
||||
|
||||
- Fixed wandb logger `global_step` affects other loggers ([#1492](https://github.com/PyTorchLightning/pytorch-lightning/issues/1485))
|
||||
|
||||
## [0.7.5] - 2020-04-27
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class LightningLoggerBase(ABC):
|
||||
"""
|
||||
agg_step, metrics_to_log = self._aggregate_metrics(metrics=metrics, step=step)
|
||||
|
||||
if metrics_to_log is not None:
|
||||
if metrics_to_log:
|
||||
self.log_metrics(metrics=metrics_to_log, step=agg_step)
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -119,9 +119,7 @@ class WandbLogger(LightningLoggerBase):
|
||||
|
||||
@rank_zero_only
|
||||
def log_metrics(self, metrics: Dict[str, float], step: Optional[int] = None) -> None:
|
||||
if step is not None:
|
||||
metrics['global_step'] = step
|
||||
self.experiment.log(metrics)
|
||||
self.experiment.log(metrics, step=step)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
||||
@@ -14,11 +14,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})
|
||||
wandb.init().log.assert_called_once_with({'acc': 1.0}, step=None)
|
||||
|
||||
wandb.init().log.reset_mock()
|
||||
logger.log_metrics({'acc': 1.0}, step=3)
|
||||
wandb.init().log.assert_called_once_with({'global_step': 3, 'acc': 1.0})
|
||||
wandb.init().log.assert_called_once_with({'acc': 1.0}, step=3)
|
||||
|
||||
logger.log_hyperparams({'test': None})
|
||||
wandb.init().config.update.assert_called_once_with({'test': None}, allow_val_change=True)
|
||||
|
||||
Reference in New Issue
Block a user