Skip to content

Commit

Permalink
update summary.proto (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanpa committed Jun 21, 2019
1 parent e932310 commit 059d088
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 46 deletions.
43 changes: 22 additions & 21 deletions tensorboardX/proto/summary.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ message SummaryMetadata {
// The name of the plugin this data pertains to.
string plugin_name = 1;

// The content to store for the plugin. The best practice is for this JSON
// string to be the canonical JSON serialization of a protocol buffer
// defined by the plugin. Converting that protobuf to and from JSON is the
// responsibility of the plugin code, and is not enforced by
// TensorFlow/TensorBoard.
string content = 2;
// The content to store for the plugin. The best practice is for this to be
// a binary serialized protocol buffer.
bytes content = 2;
}

// A list of plugin data. A single summary value instance may be used by more
// than 1 plugin.
repeated PluginData plugin_data = 1;
// Data that associates a summary with a certain plugin.
PluginData plugin_data = 1;

// Display name for viewing in TensorBoard.
string display_name = 2;

// Longform readable description of the summary sequence. Markdown supported.
string summary_description = 3;
};

// A Summary is a set of named values to be displayed by the
Expand Down Expand Up @@ -91,22 +93,21 @@ message Summary {
}

message Value {
// Name of the node that output this summary; in general, the name of a
// TensorSummary node. If the node in question has multiple outputs, then
// a ":\d+" suffix will be appended, like "some_op:13".
// Might not be set for legacy summaries (i.e. those not using the tensor
// value field)
// This field is deprecated and will not be set.
string node_name = 7;

// Tag name for the data. Will only be used by legacy summaries
// (ie. those not using the tensor value field)
// For legacy summaries, will be used as the title of the graph
// in the visualizer.
//
// Tag is usually "op_name:value_name", where "op_name" itself can have
// structure to indicate grouping.
// Tag name for the data. Used by TensorBoard plugins to organize data. Tags
// are often organized by scope (which contains slashes to convey
// hierarchy). For example: foo/bar/0
string tag = 1;

// Contains metadata on the summary value such as which plugins may use it.
// Take note that many summary values may lack a metadata field. This is
// because the FileWriter only keeps a metadata object on the first summary
// value with a certain tag for each tag. TensorBoard then remembers which
// tags are associated with which plugins. This saves space.
SummaryMetadata metadata = 9;

// Value associated with the tag.
oneof value {
float simple_value = 2;
Expand Down
46 changes: 30 additions & 16 deletions tensorboardX/proto/summary_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions tensorboardX/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def custom_scalars(layout):
categories.append(layout_pb2.Category(title=k, chart=charts))

layout = layout_pb2.Layout(category=categories)
PluginData = [SummaryMetadata.PluginData(plugin_name='custom_scalars')]
PluginData = SummaryMetadata.PluginData(plugin_name='custom_scalars')
smd = SummaryMetadata(plugin_data=PluginData)
tensor = TensorProto(dtype='DT_STRING',
string_val=[layout.SerializeToString()],
Expand All @@ -386,8 +386,8 @@ def custom_scalars(layout):

def text(tag, text):
import json
PluginData = [SummaryMetadata.PluginData(
plugin_name='text', content=TextPluginData(version=0).SerializeToString())]
PluginData = SummaryMetadata.PluginData(
plugin_name='text', content=TextPluginData(version=0).SerializeToString())
smd = SummaryMetadata(plugin_data=PluginData)
tensor = TensorProto(dtype='DT_STRING',
string_val=[text.encode(encoding='utf_8')],
Expand All @@ -401,8 +401,8 @@ def pr_curve_raw(tag, tp, fp, tn, fn, precision, recall, num_thresholds=127, wei
data = np.stack((tp, fp, tn, fn, precision, recall))
pr_curve_plugin_data = PrCurvePluginData(
version=0, num_thresholds=num_thresholds).SerializeToString()
PluginData = [SummaryMetadata.PluginData(
plugin_name='pr_curves', content=pr_curve_plugin_data)]
PluginData = SummaryMetadata.PluginData(
plugin_name='pr_curves', content=pr_curve_plugin_data)
smd = SummaryMetadata(plugin_data=PluginData)
tensor = TensorProto(dtype='DT_FLOAT',
float_val=data.reshape(-1).tolist(),
Expand All @@ -418,8 +418,8 @@ def pr_curve(tag, labels, predictions, num_thresholds=127, weights=None):
num_thresholds=num_thresholds, weights=weights)
pr_curve_plugin_data = PrCurvePluginData(
version=0, num_thresholds=num_thresholds).SerializeToString()
PluginData = [SummaryMetadata.PluginData(
plugin_name='pr_curves', content=pr_curve_plugin_data)]
PluginData = SummaryMetadata.PluginData(
plugin_name='pr_curves', content=pr_curve_plugin_data)
smd = SummaryMetadata(plugin_data=PluginData)
tensor = TensorProto(dtype='DT_FLOAT',
float_val=data.reshape(-1).tolist(),
Expand Down Expand Up @@ -470,9 +470,9 @@ def _get_tensor_summary(tag, tensor, content_type, json_config):
)
content = mesh_plugin_data.SerializeToString()
smd = SummaryMetadata(
plugin_data=[SummaryMetadata.PluginData(
plugin_data=SummaryMetadata.PluginData(
plugin_name='mesh',
content=content)])
content=content))

tensor = TensorProto(dtype='DT_FLOAT',
float_val=tensor.reshape(-1).tolist(),
Expand Down

0 comments on commit 059d088

Please sign in to comment.