From 93ed86f17567128f9cac2767da2f134203320f0b Mon Sep 17 00:00:00 2001 From: Sven Mika Date: Wed, 5 Feb 2020 21:02:39 +0100 Subject: [PATCH] =?UTF-8?q?[Tune]=20logger.py:=20Relax=20TBX=20Summary=20V?= =?UTF-8?q?alueErrors=20with=20e.g.=20empty=20lists=20in=20lists=20(and=20?= =?UTF-8?q?all=E2=80=A6=20(#6987)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/ray/tune/logger.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/python/ray/tune/logger.py b/python/ray/tune/logger.py index f83f91dfe..176dc467b 100644 --- a/python/ray/tune/logger.py +++ b/python/ray/tune/logger.py @@ -350,6 +350,7 @@ class TBXLogger(Logger): flat_result = flatten_dict(tmp, delimiter="/") path = ["ray", "tune"] valid_result = {} + for attr, value in flat_result.items(): full_attr = "/".join(path + [attr]) if type(value) in VALID_SUMMARY_TYPES: @@ -358,8 +359,16 @@ class TBXLogger(Logger): full_attr, value, global_step=step) elif type(value) is list and len(value) > 0: valid_result[full_attr] = value - self._file_writer.add_histogram( - full_attr, value, global_step=step) + try: + self._file_writer.add_histogram( + full_attr, value, global_step=step) + # In case TensorboardX still doesn't think it's a valid value + # (e.g. `[[]]`), warn and move on. + except ValueError: + logger.warning( + "You are trying to log an invalid value ({}={}) " + "via {}!".format(full_attr, value, + type(self).__name__)) self.last_result = valid_result self._file_writer.flush()