4
4
5
5
The * custom* scalar dashboard lets users
6
6
7
- 1 . Create line charts with custom combinations of runs and tags by assigning
7
+ * Create line charts with custom combinations of runs and tags by assigning
8
8
each chart a list of regular expressions for tags.
9
- 2 . Lay out the dashboard in a customized way.
9
+ * Create margin charts (for visualizing confidence intervals).
10
+ * Lay out the dashboard in a customized way.
10
11
11
12
To use this dashboard, users first collect scalar data and then lay out the UI.
12
13
@@ -59,8 +60,7 @@ op but rather a Summary proto that be passed to the SummaryWriter (See sample
59
60
code.).
60
61
61
62
The ` Layout ` proto encapsulates the organization of the dashboard. See
62
- [ layout.proto] ( layout.proto ) for documentation. See the code below for an
63
- example of how to use it.
63
+ [ layout.proto] ( layout.proto ) for documentation.
64
64
65
65
### Specifying a Layout via a TensorFlow op instead
66
66
@@ -73,67 +73,16 @@ to change the layout over time.
73
73
74
74
### Example Code
75
75
76
- ``` python
77
- from tensorboard import summary as summary_lib
78
- from tensorboard.plugins.custom_scalar import layout_pb2
79
- import tensorflow as tf
80
-
81
- step = tf.placeholder(tf.float32, shape = [])
82
-
83
- with tf.name_scope(' loss' ):
84
- # Specify 2 different loss values, each tagged differently.
85
- summary_lib.scalar(' foo' , tf.pow(0.9 , step))
86
- summary_lib.scalar(' bar' , tf.pow(0.85 , step + 2 ))
87
-
88
- # Log metric baz as well as upper and lower bounds for making a margin chart.
89
- middle_baz_value = step + 4 * tf.random_uniform() - 2
90
- summary_lib.scalar(' baz' , middle_baz_value)
91
- summary_lib.scalar(' baz_lower' , middle_baz_value - 0.3 - tf.random_uniform())
92
- summary_lib.scalar(' baz_upper' , middle_baz_value + 0.3 + tf.random_uniform())
93
-
94
- with tf.name_scope(' trigFunctions' ):
95
- summary_lib.scalar(' cosine' , tf.cos(step))
96
- summary_lib.scalar(' sine' , tf.sin(step))
97
- summary_lib.scalar(' tangent' , tf.tan(step))
98
-
99
- merged_summary = tf.summary.merge_all()
100
-
101
- with tf.Session() as sess, tf.summary.FileWriter(' /tmp/logdir' ) as writer:
102
- # We only need to specify the layout once (instead of per step).
103
- summary_lib.custom_scalar_pb(layout_pb2.Layout(
104
- category = [
105
- layout_pb2.Category(
106
- title = ' losses in 1 chart' ,
107
- chart = [
108
- layout_pb2.Chart(
109
- title = ' losses' ,
110
- tag = [r ' loss. * ' ]),
111
- ]),
112
- layout_pb2.Category(
113
- title = ' trig functions' ,
114
- chart = [
115
- layout_pb2.Chart(
116
- title = ' wave trig functions' ,
117
- tag = [r ' trigFunctions/cosine' , r ' trigFunctions/sine' ]),
118
- # The range of tangent is different. Lets give it its own chart.
119
- layout_pb2.Chart(
120
- title = ' tan' ,
121
- tag = [r ' trigFunctions/tangent' ]),
122
- ],
123
- # This category we care less about. Lets make it initially closed.
124
- closed = True ),
125
- ]))
126
-
127
- for i in xrange (42 ):
128
- summary = sess.run(merged_summary, feed_dict = {step: i})
129
- writer.add_summary(summary, global_step = i)
130
- ```
76
+ See [ custom_scalar_demo.py] ( custom_scalar_demo.py ) for an example of collecting
77
+ scalar data and then laying out the dashboard in a customized way.
131
78
132
- ## The Dashboard UI
79
+ The example layout contains both multi-line charts and margin charts.
133
80
134
- The above logic produces this custom scalar dashboard.
81
+ ## Example of the Custom Scalar Dashboard UI
135
82
136
- ![ Dashboard for demo code] ( docs/sample_code_dashboard.png )
83
+ The logic within the demo produces this custom scalar dashboard.
84
+
85
+ ![ Dashboard for demo code] ( docs/demo_code_dashboard.png )
137
86
138
87
Note that the layout mirrors the ` layout_pb2.Layout ` proto that we had passed to
139
88
the ` summary_lib.custom_scalar_pb ` method. Specifically, we have 2 categories:
@@ -144,6 +93,9 @@ obtained by the regular expression `r'loss.*'`. Because the 2 tags are for the
144
93
same run, the 2 lines differ in markers (One uses squares, while the other uses
145
94
diamonds.) to be distinct from each other. Color still encodes the run.
146
95
96
+ The baz chart is a margin chart. Zoom in (by dragging a rectangle) or hover over
97
+ points to view margin values. Smoothing does not affect margin charts.
98
+
147
99
If we expand the "trig functions" category, we find that lines for sine and
148
100
cosine are within one chart, and the line for tangent resides in a separate one
149
101
(as expected).
0 commit comments