Ejemplo n.º 1
0
 def _make_plan(self):
   p = plan.EvalPlan()
   p.compiler = block_compiler.Compiler.create(blocks.Scalar())
   temp_dir = self.get_temp_dir()
   p.logdir = os.path.join(temp_dir, 'eval')
   p.logdir_restore = os.path.join(temp_dir, 'train')
   p.examples = [2, 4]
   p.print_file = six.StringIO()
   p.losses['loss'] = p.compiler.output_tensors[0]
   p.metrics['foo'] = tf.constant(42.0)
   p.finalize_stats()
   return p
Ejemplo n.º 2
0
 def test_assert_runnable(self):
   p = plan.EvalPlan()
   self.assertRaisesWithLiteralMatch(
       ValueError, 'compiler is required', p.assert_runnable)
   p.compiler = block_compiler.Compiler.create(blocks.Scalar())
   p.logdir = '/tmp/'
   self.assertRaisesWithLiteralMatch(
       ValueError, 'examples is required', p.assert_runnable)
   p.examples = xrange(5)
   self.assertRaisesWithLiteralMatch(
       ValueError, 'at least one loss is required', p.assert_runnable)
   p.losses['foo'] = tf.constant(42.0)
   p.finalize_stats()
   self.assertRaisesWithLiteralMatch(
       ValueError, 'logdir_restore is required', p.assert_runnable)
   p.logdir_restore = '/tmp/foo/'
   p.assert_runnable()