Skip to content

Commit

Permalink
[Tune] logger.py: Relax TBX Summary ValueErrors with e.g. empty lists…
Browse files Browse the repository at this point in the history
… in lists (and all… (#6987)
  • Loading branch information
sven1977 committed Feb 5, 2020
1 parent 0e39608 commit 93ed86f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions python/ray/tune/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def on_result(self, result):
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:
Expand All @@ -358,8 +359,16 @@ def on_result(self, result):
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()
Expand Down

0 comments on commit 93ed86f

Please sign in to comment.