def run(hparams, run_dir):
  """Run train/eval/test."""
  train_dir = os.path.join(run_dir, 'train')

  if FLAGS.mode == 'eval':
    eval_dir = os.path.join(run_dir, 'eval')
    if FLAGS.eval_dir:
      eval_dir = os.path.join(eval_dir, FLAGS.eval_dir)
    train_util.evaluate(
        train_dir=train_dir,
        eval_dir=eval_dir,
        examples_path=FLAGS.examples_path,
        num_batches=FLAGS.eval_num_batches,
        hparams=hparams)
  elif FLAGS.mode == 'test':
    checkpoint_path = (os.path.expanduser(FLAGS.checkpoint_path)
                       if FLAGS.checkpoint_path else
                       tf.train.latest_checkpoint(train_dir))
    tf.logging.info('Testing with checkpoint: %s', checkpoint_path)
    test_dir = os.path.join(run_dir, 'test')
    train_util.test(
        checkpoint_path=checkpoint_path,
        test_dir=test_dir,
        examples_path=FLAGS.examples_path,
        num_batches=FLAGS.eval_num_batches,
        hparams=hparams)
  elif FLAGS.mode == 'train':
    train_util.train(
        train_dir=train_dir,
        examples_path=FLAGS.examples_path,
        hparams=hparams,
        checkpoints_to_keep=FLAGS.checkpoints_to_keep,
        num_steps=FLAGS.num_steps)
  else:
    raise ValueError('Invalid mode: {}'.format(FLAGS.mode))
def run(hparams, run_dir):
    """Run train/eval/test."""
    train_dir = os.path.join(run_dir, 'train')

    if FLAGS.mode == 'eval':
        eval_dir = os.path.join(run_dir, 'eval')
        if FLAGS.eval_dir:
            eval_dir = os.path.join(eval_dir, FLAGS.eval_dir)
        train_util.evaluate(train_dir=train_dir,
                            eval_dir=eval_dir,
                            examples_path=FLAGS.examples_path,
                            num_batches=FLAGS.eval_num_batches,
                            hparams=hparams)
    elif FLAGS.mode == 'test':
        checkpoint_path = (os.path.expanduser(FLAGS.checkpoint_path)
                           if FLAGS.checkpoint_path else
                           tf.train.latest_checkpoint(train_dir))
        tf.logging.info('Testing with checkpoint: %s', checkpoint_path)
        test_dir = os.path.join(run_dir, 'test')
        train_util.test(checkpoint_path=checkpoint_path,
                        test_dir=test_dir,
                        examples_path=FLAGS.examples_path,
                        num_batches=FLAGS.eval_num_batches,
                        hparams=hparams)
    elif FLAGS.mode == 'train':
        train_util.train(train_dir=train_dir,
                         examples_path=FLAGS.examples_path,
                         hparams=hparams,
                         checkpoints_to_keep=FLAGS.checkpoints_to_keep,
                         num_steps=FLAGS.num_steps)
    else:
        raise ValueError('Invalid mode: {}'.format(FLAGS.mode))
def run(hparams, run_dir):
  """Run train/eval/test."""
  train_dir = os.path.join(run_dir, 'train')

  if FLAGS.mode == 'eval':
    eval_dir = os.path.join(run_dir, 'eval')
    if FLAGS.eval_dir:
      eval_dir = os.path.join(eval_dir, FLAGS.eval_dir)
    train_util.evaluate(
        train_dir=train_dir,
        eval_dir=eval_dir,
        examples_path=FLAGS.examples_path,
        num_batches=FLAGS.eval_num_batches,
        hparams=hparams,
        master=FLAGS.master)
  elif FLAGS.mode == 'test':
    checkpoint_path = tf.train.latest_checkpoint(train_dir)
    if FLAGS.checkpoint_path:
      checkpoint_path = os.path.expanduser(FLAGS.checkpoint_path)

    tf.logging.info('Testing with checkpoint: %s', checkpoint_path)
    test_dir = os.path.join(run_dir, 'test')
    train_util.test(
        checkpoint_path=checkpoint_path,
        test_dir=test_dir,
        examples_path=FLAGS.examples_path,
        num_batches=FLAGS.eval_num_batches,
        hparams=hparams,
        master=FLAGS.master)
  elif FLAGS.mode == 'train':
    train_util.train(
        train_dir=train_dir,
        examples_path=FLAGS.examples_path,
        hparams=hparams,
        checkpoints_to_keep=FLAGS.checkpoints_to_keep,
        num_steps=FLAGS.num_steps,
        master=FLAGS.master,
        task=FLAGS.ps_task,
        num_ps_tasks=FLAGS.num_ps_tasks)
示例#4
0
def run(hparams, run_dir):
    """Run train/eval/test."""
    train_dir = os.path.join(run_dir, 'train')

    if FLAGS.mode == 'eval':
        eval_dir = os.path.join(run_dir, 'eval')
        if FLAGS.eval_dir:
            eval_dir = os.path.join(eval_dir, FLAGS.eval_dir)
        train_util.evaluate(train_dir=train_dir,
                            eval_dir=eval_dir,
                            examples_path=FLAGS.examples_path,
                            num_batches=FLAGS.eval_num_batches,
                            hparams=hparams,
                            master=FLAGS.master)
    elif FLAGS.mode == 'test':
        checkpoint_path = tf.train.latest_checkpoint(train_dir)
        if FLAGS.checkpoint_path:
            checkpoint_path = os.path.expanduser(FLAGS.checkpoint_path)

        tf.logging.info('Testing with checkpoint: %s', checkpoint_path)
        test_dir = os.path.join(run_dir, 'test')
        train_util.test(checkpoint_path=checkpoint_path,
                        test_dir=test_dir,
                        examples_path=FLAGS.examples_path,
                        num_batches=FLAGS.eval_num_batches,
                        hparams=hparams,
                        master=FLAGS.master)
    elif FLAGS.mode == 'train':
        train_util.train(train_dir=train_dir,
                         examples_path=FLAGS.examples_path,
                         hparams=hparams,
                         checkpoints_to_keep=FLAGS.checkpoints_to_keep,
                         num_steps=FLAGS.num_steps,
                         master=FLAGS.master,
                         task=FLAGS.ps_task,
                         num_ps_tasks=FLAGS.num_ps_tasks)