Example #1
0
 def test_run_no_key_fn(self):
   p = plan.InferPlan()
   p.compiler = block_compiler.Compiler.create(
       blocks.Scalar() >> blocks.Function(tf.negative))
   p.logdir = self.get_temp_dir()
   p.examples = xrange(5)
   p.outputs = p.compiler.output_tensors
   results = []
   p.results_fn = results.append
   p.batch_size = 3
   p.chunk_size = 2
   with self.test_session() as sess:
     p.run(session=sess)
   self.assertEqual(1, len(results))
   self.assertEqual([(0,), (-1,), (-2,), (-3,), (-4,)], list(results[0]))
Example #2
0
 def test_assert_runnable(self):
   p = plan.InferPlan()
   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, 'outputs is required', p.assert_runnable)
   p.outputs = tf.placeholder(tf.float32)
   p.assert_runnable()
   p.batch_size = None
   self.assertRaisesWithLiteralMatch(
       ValueError, 'batch_size is required', p.assert_runnable)