Skip to content

Commit

Permalink
Related to Lightning-AI#609. Filter params for tensorboard logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamagarwal92 committed Mar 12, 2020
1 parent 30f0bf3 commit 9473303
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pytorch_lightning/loggers/tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,17 @@ def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None:
" hyperparameter logging."
)
else:
# See https://github.com/PyTorchLightning/pytorch-lightning/pull/609#issuecomment-598253152
# Passing only those params which tensorboard allows here:
# https://github.com/pytorch/pytorch/blob/master/torch/utils/tensorboard/summary.py#L134
from six import string_types
from torch.utils.tensorboard.summary import hparams
exp, ssi, sei = hparams(params, {})
tensorboard_params = {}
for k, v in params.items():
if isinstance(v, int) or isinstance(v, float) or isinstance(v, string_types) or isinstance(
v, bool) or isinstance(v, torch.Tensor):
tensorboard_params[k] = v
exp, ssi, sei = hparams(tensorboard_params, {})
writer = self.experiment._get_file_writer()
writer.add_summary(exp)
writer.add_summary(ssi)
Expand Down

0 comments on commit 9473303

Please sign in to comment.