Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
episode_rewards = layout_pb2.Category(
title="Episode Reward",
chart=gen_multiline_charts(
[
("Shaped Reward", [r"shaping/eprewmean_true"]),
("Episode Length", [r"eplenmean"]),
("Sparse Reward", [r"shaping/epsparsemean"]),
("Dense Reward", [r"shaping/epdensemean"]),
("Dense Reward Annealing", [r"shaping/rew_anneal_c"]),
("Unshaped Reward", [r"ep_rewmean"]),
("Victim Action Noise", [r"shaping/victim_noise"]),
]
),
)
game_outcome = layout_pb2.Category(
title="Game Outcomes",
chart=gen_multiline_charts(
[
("Agent 0 Win Proportion", [r"game_win0"]),
("Agent 1 Win Proportion", [r"game_win1"]),
("Tie Proportion", [r"game_tie"]),
("# of games", [r"game_total"]),
]
),
)
training = layout_pb2.Category(
title="Training",
chart=gen_multiline_charts(
[
("Policy Loss", [r"policy_loss"]),
title='losses',
multiline=layout_pb2.MultilineChartContent(
tag=[r'loss.*'],
)),
layout_pb2.Chart(
title='baz',
margin=layout_pb2.MarginChartContent(
series=[
layout_pb2.MarginChartContent.Series(
value='loss/baz/scalar_summary',
lower='baz_lower/baz/scalar_summary',
upper='baz_upper/baz/scalar_summary'),
],
)),
]),
layout_pb2.Category(
title='trig functions',
chart=[
layout_pb2.Chart(
title='wave trig functions',
multiline=layout_pb2.MultilineChartContent(
tag=[r'trigFunctions/cosine', r'trigFunctions/sine'],
)),
# The range of tangent is different. Let's give it its own chart.
layout_pb2.Chart(
title='tan',
multiline=layout_pb2.MultilineChartContent(
tag=[r'trigFunctions/tangent'],
)),
],
# This category we care less about. Let's make it initially closed.
closed=True),
title='losses',
multiline=layout_pb2.MultilineChartContent(
tag=[r'loss.*'],
)),
layout_pb2.Chart(
title='baz',
margin=layout_pb2.MarginChartContent(
series=[
layout_pb2.MarginChartContent.Series(
value='loss/baz/scalar_summary',
lower='baz_lower/baz/scalar_summary',
upper='baz_upper/baz/scalar_summary'),
],
)),
]),
layout_pb2.Category(
title='trig functions',
chart=[
layout_pb2.Chart(
title='wave trig functions',
multiline=layout_pb2.MultilineChartContent(
tag=[r'trigFunctions/cosine', r'trigFunctions/sine'],
)),
# The range of tangent is different. Let's give it its own chart.
layout_pb2.Chart(
title='tan',
multiline=layout_pb2.MultilineChartContent(
tag=[r'trigFunctions/tangent'],
)),
],
# This category we care less about. Let's make it initially closed.
closed=True),
def tb_layout():
episode_rewards = layout_pb2.Category(
title="Episode Reward",
chart=gen_multiline_charts(
[
("Shaped Reward", [r"shaping/eprewmean_true"]),
("Episode Length", [r"eplenmean"]),
("Sparse Reward", [r"shaping/epsparsemean"]),
("Dense Reward", [r"shaping/epdensemean"]),
("Dense Reward Annealing", [r"shaping/rew_anneal_c"]),
("Unshaped Reward", [r"ep_rewmean"]),
("Victim Action Noise", [r"shaping/victim_noise"]),
]
),
)
game_outcome = layout_pb2.Category(
title="Game Outcomes",
)),
layout_pb2.Chart(
title='baz',
margin=layout_pb2.MarginChartContent(
series=[
layout_pb2.MarginChartContent.Series(
value='loss/baz/scalar_summary',
lower='baz_lower/baz/scalar_summary',
upper='baz_upper/baz/scalar_summary'),
],
)),
]),
layout_pb2.Category(
title='trig functions',
chart=[
layout_pb2.Chart(
title='wave trig functions',
multiline=layout_pb2.MultilineChartContent(
tag=[r'trigFunctions/cosine', r'trigFunctions/sine'],
)),
# The range of tangent is different. Let's give it its own chart.
layout_pb2.Chart(
title='tan',
multiline=layout_pb2.MultilineChartContent(
tag=[r'trigFunctions/tangent'],
)),
],
# This category we care less about. Let's make it initially closed.
closed=True),
]))
writer.add_summary(layout_summary)
title='baz',
margin=layout_pb2.MarginChartContent(
series=[
layout_pb2.MarginChartContent.Series(
value='loss/baz/scalar_summary',
lower='baz_lower/baz/scalar_summary',
upper='baz_upper/baz/scalar_summary'),
],
)),
]),
layout_pb2.Category(
title='trig functions',
chart=[
layout_pb2.Chart(
title='wave trig functions',
multiline=layout_pb2.MultilineChartContent(
tag=[r'trigFunctions/cosine', r'trigFunctions/sine'],
)),
# The range of tangent is different. Let's give it its own chart.
layout_pb2.Chart(
title='tan',
multiline=layout_pb2.MultilineChartContent(
tag=[r'trigFunctions/tangent'],
)),
],
# This category we care less about. Let's make it initially closed.
closed=True),
]))
writer.add_summary(layout_summary)
merged_layout = None
runs = list(
self._multiplexer.PluginRunToTagToContent(metadata.PLUGIN_NAME)
)
runs.sort()
for run in runs:
tensor_events = self._multiplexer.Tensors(
run, metadata.CONFIG_SUMMARY_TAG
)
# This run has a layout. Merge it with the ones currently found.
string_array = tensor_util.make_ndarray(
tensor_events[0].tensor_proto
)
content = np.asscalar(string_array)
layout_proto = layout_pb2.Layout()
layout_proto.ParseFromString(tf.compat.as_bytes(content))
if merged_layout:
# Append the categories within this layout to the merged layout.
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, 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
]
)