def testSetLayout(self): layout_proto_to_write = layout_pb2.Layout(category=[ layout_pb2.Category( title='mean biases', chart=[ layout_pb2.Chart( title='mean layer biases', multiline=layout_pb2.MultilineChartContent( tag=[r'mean/layer\d+/biases'], )), ]), layout_pb2.Category( title='std weights', chart=[ layout_pb2.Chart( title='stddev layer weights', multiline=layout_pb2.MultilineChartContent( tag=[r'stddev/layer\d+/weights'], )), ]), layout_pb2.Category( title='cross entropy ... and maybe some other values', chart=[ layout_pb2.Chart( title='cross entropy', multiline=layout_pb2.MultilineChartContent( tag=[r'cross entropy'], )), layout_pb2.Chart( title='accuracy', margin=layout_pb2.MarginChartContent(series=[ layout_pb2.MarginChartContent.Series( value='accuracy', lower='accuracy_lower_margin', upper='accuracy_upper_margin') ])), layout_pb2.Chart( title='max layer weights', multiline=layout_pb2.MultilineChartContent( tag=[r'max/layer1/.*', r'max/layer2/.*'], )), ], closed=True) ]) # Write the data as a summary for the '.' run. with tf.Session() as s, tf.summary.FileWriter(self.logdir) as writer: writer.add_summary(s.run(summary.op(layout_proto_to_write))) # Read the data from disk. multiplexer = event_multiplexer.EventMultiplexer() multiplexer.AddRunsFromDirectory(self.logdir) multiplexer.Reload() tensor_events = multiplexer.Tensors('.', metadata.CONFIG_SUMMARY_TAG) self.assertEqual(1, len(tensor_events)) # Parse the data. string_array = tf.make_ndarray(tensor_events[0].tensor_proto) content = np.asscalar(string_array) layout_proto_from_disk = layout_pb2.Layout() layout_proto_from_disk.ParseFromString(tf.compat.as_bytes(content)) # Verify the content. self.assertProtoEquals(layout_proto_to_write, layout_proto_from_disk)
def testSetLayout(self): layout_proto_to_write = layout_pb2.Layout( category=[ layout_pb2.Category( title='mean biases', chart=[ layout_pb2.Chart( title='mean layer biases', multiline=layout_pb2.MultilineChartContent( tag=[r'mean/layer\d+/biases'], )), ]), layout_pb2.Category( title='std weights', chart=[ layout_pb2.Chart( title='stddev layer weights', multiline=layout_pb2.MultilineChartContent( tag=[r'stddev/layer\d+/weights'], )), ]), layout_pb2.Category( title='cross entropy ... and maybe some other values', chart=[ layout_pb2.Chart( title='cross entropy', multiline=layout_pb2.MultilineChartContent( tag=[r'cross entropy'], )), layout_pb2.Chart( title='accuracy', margin=layout_pb2.MarginChartContent( series=[ layout_pb2.MarginChartContent.Series( value='accuracy', lower='accuracy_lower_margin', upper='accuracy_upper_margin') ] )), layout_pb2.Chart( title='max layer weights', multiline=layout_pb2.MultilineChartContent( tag=[r'max/layer1/.*', r'max/layer2/.*'], )), ], closed=True) ]) # Write the data as a summary for the '.' run. with tf.Session() as s, tf.summary.FileWriter(self.logdir) as writer: writer.add_summary(s.run(summary.op(layout_proto_to_write))) # Read the data from disk. multiplexer = event_multiplexer.EventMultiplexer() multiplexer.AddRunsFromDirectory(self.logdir) multiplexer.Reload() tensor_events = multiplexer.Tensors('.', metadata.CONFIG_SUMMARY_TAG) self.assertEqual(1, len(tensor_events)) # Parse the data. string_array = tf.make_ndarray(tensor_events[0].tensor_proto) content = np.asscalar(string_array) layout_proto_from_disk = layout_pb2.Layout() layout_proto_from_disk.ParseFromString(tf.compat.as_bytes(content)) # Verify the content. self.assertProtoEquals(layout_proto_to_write, layout_proto_from_disk)