def testTFSummaryScalar(self): """Verify processing of tf.summary.scalar.""" event_sink = _EventGenerator(self, zero_out_timestamps=True) writer = SummaryToEventTransformer(event_sink) with self.test_session() as sess: ipt = tf.placeholder(tf.float32) tf.summary.scalar('scalar1', ipt) tf.summary.scalar('scalar2', ipt * ipt) merged = tf.summary.merge_all() writer.add_graph(sess.graph) for i in xrange(10): summ = sess.run(merged, feed_dict={ipt: i}) writer.add_summary(summ, global_step=i) accumulator = ea.EventAccumulator(event_sink) accumulator.Reload() seq1 = [ea.ScalarEvent(wall_time=0, step=i, value=i) for i in xrange(10)] seq2 = [ ea.ScalarEvent( wall_time=0, step=i, value=i * i) for i in xrange(10) ] self.assertTagsEqual(accumulator.Tags(), { ea.SCALARS: ['scalar1', 'scalar2'], ea.GRAPH: True, ea.META_GRAPH: False, }) self.assertEqual(accumulator.Scalars('scalar1'), seq1) self.assertEqual(accumulator.Scalars('scalar2'), seq2) first_value = accumulator.Scalars('scalar1')[0].value self.assertTrue(isinstance(first_value, float))
def testScalars(self): gen = _EventGenerator(self) acc = ea.EventAccumulator(gen) s1 = ea.ScalarEvent(wall_time=1, step=10, value=32) s2 = ea.ScalarEvent(wall_time=2, step=12, value=64) gen.AddScalar('s1', wall_time=1, step=10, value=32) gen.AddScalar('s2', wall_time=2, step=12, value=64) acc.Reload() self.assertEqual(acc.Scalars('s1'), [s1]) self.assertEqual(acc.Scalars('s2'), [s2])
def testScalars(self): """Tests whether EventAccumulator contains scalars after adding them.""" gen = _EventGenerator(self) acc = ea.EventAccumulator(gen) s1 = ea.ScalarEvent(wall_time=1, step=10, value=32) s2 = ea.ScalarEvent(wall_time=2, step=12, value=64) gen.AddScalar('s1', wall_time=1, step=10, value=32) gen.AddScalar('s2', wall_time=2, step=12, value=64) acc.Reload() self.assertEqual(acc.Scalars('s1'), [s1]) self.assertEqual(acc.Scalars('s2'), [s2])