plan_test.py 文件源码

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

项目:fold 作者: tensorflow 项目源码 文件源码
def test_run_once(self):
    p = self._make_plan()
    p.save_best = False
    # We aren't using a managed session, so we need to run this ourselves.
    init_op = tf.global_variables_initializer()
    sv = p.create_supervisor()
    with self.test_session() as sess:
      p.run(sv, sess)
      log_str = p.print_file.getvalue()
      self.assertTrue(
          log_str.endswith('could not restore from %s\n' % p.logdir_restore),
          msg=log_str)

      p.print_file = six.StringIO()
      sess.run(init_op)
      tf.gfile.MkDir(p.logdir_restore)
      save_path = os.path.join(p.logdir_restore, 'model')
      sv.saver.save(sess, save_path, global_step=42)
      p.run(sv, sess)
      log_str = p.print_file.getvalue()
      expected_lines = ['restoring from %s-42' % save_path,
                        'step:       0 loss: 3.000e+00 foo: 4.200e+01']
      expected = '\n'.join(expected_lines) + '\n'
      self.assertTrue(log_str.endswith(expected), msg=log_str)
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号