From 44ffb2985d08824297a767ddb7b6249b735940b0 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Wed, 25 Sep 2019 00:31:23 +0300 Subject: [PATCH] Change tensorboard default scalar grouping (now False) --- trains/binding/frameworks/tensorflow_bind.py | 4 +++- trains/logger.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/trains/binding/frameworks/tensorflow_bind.py b/trains/binding/frameworks/tensorflow_bind.py index 6385e214..63f6d8f2 100644 --- a/trains/binding/frameworks/tensorflow_bind.py +++ b/trains/binding/frameworks/tensorflow_bind.py @@ -238,7 +238,9 @@ class EventTrainsWriter(object): return self._add_image_numpy(tag=tag, step=step, img_data_np=matrix) def _add_scalar(self, tag, step, scalar_data): - title, series = self.tag_splitter(tag, num_split_parts=1, default_title='Scalars', logdir_header='series_last') + default_title = tag if not self._logger._get_tensorboard_auto_group_scalars() else 'Scalars' + title, series = self.tag_splitter(tag, num_split_parts=1, + default_title=default_title, logdir_header='series_last') # update scalar cache num, value = self._scalar_report_cache.get((title, series), (0, 0)) diff --git a/trains/logger.py b/trains/logger.py index edc12c76..3e472678 100644 --- a/trains/logger.py +++ b/trains/logger.py @@ -23,6 +23,7 @@ class Logger(object): **Usage:** :func:`Logger.current_logger` or :func:`Task.get_logger` """ SeriesInfo = SeriesInfo + _tensorboard_logging_auto_group_scalars = False def __init__(self, private_task): """ @@ -444,6 +445,15 @@ class Logger(object): self.report_image(title=title, series=series, iteration=iteration, local_path=path, matrix=matrix, max_image_history=max_image_history, delete_after_upload=delete_after_upload) + @classmethod + def tensorboard_auto_group_scalars(cls, group_scalars=False): + """ + If `group_scalars` set to True, we preserve backward compatible Tensorboard auto-magic behaviour, + i.e. Scalars without specific title will be grouped under the "Scalars" graph. + Default is False: Tensorboard scalars without title will have title/series with the same tag + """ + cls._tensorboard_logging_auto_group_scalars = group_scalars + @classmethod def _remove_std_logger(cls): StdStreamPatch.remove_std_logger() @@ -595,3 +605,12 @@ class Logger(object): def _flush_stdout_handler(self): if self._task_handler and DevWorker.report_stdout: self._task_handler.flush() + + @classmethod + def _get_tensorboard_auto_group_scalars(cls): + """ + :return: return True if we preserve Tensorboard backward compatibility behaviour, + i.e. Scalars without specific title will be under the "Scalars" graph + default is False: Tensorboard scalars without title will have title/series with the same tag + """ + return cls._tensorboard_logging_auto_group_scalars