def test_assert_runnable(self):
p = plan.TrainPlan()
self.assertRaisesWithLiteralMatch(
ValueError, 'at least one loss is required', p.assert_runnable)
p.losses['foo'] = tf.constant(42.0)
self.assertRaisesWithLiteralMatch(
ValueError, 'compiler is required', p.assert_runnable)
p.compiler = block_compiler.Compiler.create(blocks.Scalar())
self.assertRaisesWithLiteralMatch(
RuntimeError, 'finalize_stats() has not been called', p.assert_runnable)
p.finalize_stats()
self.assertRaisesWithLiteralMatch(
ValueError, 'logdir is required', p.assert_runnable)
p.logdir = '/tmp/'
self.assertRaisesWithLiteralMatch(
ValueError, 'train_op is required', p.assert_runnable)
p.train_op = tf.no_op()
self.assertRaisesWithLiteralMatch(
ValueError, 'batch_size is required', p.assert_runnable)
p.batch_size = 10
self.assertRaisesWithLiteralMatch(
ValueError, 'either examples or batches_per_epoch is required',
p.assert_runnable)
p.examples = xrange(2)
p.assert_runnable()
p.examples = None
self.assertRaises(ValueError, p.assert_runnable)
p.batches_per_epoch = 42
p.assert_runnable()
评论列表
文章目录