Skip to content

Commit

Permalink
Fix custom_scalar displaying duplicated charts
Browse files Browse the repository at this point in the history
  • Loading branch information
lgeiger committed Jul 18, 2018
1 parent 6b01220 commit efd6edd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions tensorboard/plugins/custom_scalar/custom_scalars_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,11 @@ def layout_impl(self):
for category in layout_proto.category:
if category.title in title_to_category:
# A category with this name has been seen before. Do not create a
# new one. Merge their charts.
title_to_category[category.title].chart.extend(category.chart)
# new one. Merge their charts, skipping any duplicates.
title_to_category[category.title].chart.extend([
c for c in category.chart
if c not in title_to_category[category.title].chart
])
else:
# This category has not been seen before.
merged_layout.category.add().MergeFrom(category)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, *args, **kwargs):
]
),
# A category with this name is also present in a layout for a
# different run (the logdir run)
# different run (the logdir run) and also contains a duplicate chart
layout_pb2.Category(
title='cross entropy',
chart=[
Expand All @@ -92,6 +92,11 @@ def __init__(self, *args, **kwargs):
upper='cross entropy upper'),
],
)),
layout_pb2.Chart(
title='cross entropy',
multiline=layout_pb2.MultilineChartContent(
tag=[r'cross entropy'],
)),
]
),
]
Expand Down

0 comments on commit efd6edd

Please sign in to comment.