def testScalarSummaryIsPartOfCollectionWithPrint(self): tensor = array_ops.ones([]) * 3 name = 'my_score' prefix = 'eval' op = summaries.add_scalar_summary(tensor, name, prefix, print_summary=True) self.assertIn(op, ops.get_collection(ops.GraphKeys.SUMMARIES))
def verify_scalar_summary_is_written(self, print_summary): value = 3 tensor = array_ops.ones([]) * value name = 'my_score' prefix = 'eval' summaries.add_scalar_summary(tensor, name, prefix, print_summary) output_dir = tempfile.mkdtemp('scalar_summary_no_print_test') summary_op = summary.merge_all() summary_writer = summary.FileWriter(output_dir) with self.cached_session() as sess: new_summary = sess.run(summary_op) summary_writer.add_summary(new_summary, 1) summary_writer.flush() self.assert_scalar_summary(output_dir, {'%s/%s' % (prefix, name): value})