plan_test.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:fold 作者: tensorflow 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号