(build_graph_fn, train_dir, eval_dir, num_batches,
             timeout_secs=300)
Runs the training loop.

  Args:
    build_graph_fn: A function that builds the graph ops.
    train_dir: The path to the directory where checkpoints will be loaded
        from for evaluation.
    eval_dir: The path to the directory where the evaluation summary events
        will be written to.
    num_batches: The number of full batches to use for each evaluation step.
    timeout_secs: The number of seconds after which to stop waiting for a new
        checkpoint.
  Raises:
    ValueError: If `num_batches` is less than or equal to 0.
Runs the training loop.
Runs the training loop .
def run_eval(build_graph_fn, train_dir, eval_dir, num_batches,
             timeout_secs=300):
  """Runs the training loop.

  Args:
    build_graph_fn: A function that builds the graph ops.
    train_dir: The path to the directory where checkpoints will be loaded
        from for evaluation.
    eval_dir: The path to the directory where the evaluation summary events
        will be written to.
    num_batches: The number of full batches to use for each evaluation step.
    timeout_secs: The number of seconds after which to stop waiting for a new
        checkpoint.
  Raises:
    ValueError: If `num_batches` is less than or equal to 0.
  """
  if num_batches <= 0:
    raise ValueError(
        '`num_batches` must be greater than 0. Check that the batch size is '
        'no larger than the number of records in the eval set.')
  with tf.Graph().as_default():
    build_graph_fn()

    global_step = tf.train.get_or_create_global_step()
    loss = tf.get_collection('loss')[0]
    perplexity = tf.get_collection('metrics/perplexity')[0]
    accuracy = tf.get_collection('metrics/accuracy')[0]
    eval_ops = tf.get_collection('eval_ops')

    logging_dict = {
        'Global Step': global_step,
        'Loss': loss,
        'Perplexity': perplexity,
        'Accuracy': accuracy
    }
    hooks = [
        EvalLoggingTensorHook(logging_dict, every_n_iter=num_batches),
        tf_slim.evaluation.StopAfterNEvalsHook(num_batches),
        tf_slim.evaluation.SummaryAtEndHook(eval_dir),
    ]

    tf_slim.evaluation.evaluate_repeatedly(
        train_dir,
        eval_ops=eval_ops,
        hooks=hooks,
        eval_interval_secs=60,
        timeout=timeout_secs)
def run_eval ( build_graph_fn , train_dir , eval_dir , num_batches , timeout_secs = 300 ) : if num_batches <= 0 : raise ValueError ( '`num_batches` must be greater than 0. Check that the batch size is ' 'no larger than the number of records in the eval set.' ) with tf . Graph ( ) . as_default ( ) : build_graph_fn ( ) global_step = tf . train . get_or_create_global_step ( ) loss = tf . get_collection ( 'loss' ) [ 0 ] perplexity = tf . get_collection ( 'metrics/perplexity' ) [ 0 ] accuracy = tf . get_collection ( 'metrics/accuracy' ) [ 0 ] eval_ops = tf . get_collection ( 'eval_ops' ) logging_dict = { 'Global Step' : global_step , 'Loss' : loss , 'Perplexity' : perplexity , 'Accuracy' : accuracy } hooks = [ EvalLoggingTensorHook ( logging_dict , every_n_iter = num_batches ) , tf_slim . evaluation . StopAfterNEvalsHook ( num_batches ) , tf_slim . evaluation . SummaryAtEndHook ( eval_dir ) , ] tf_slim . evaluation . evaluate_repeatedly ( train_dir , eval_ops = eval_ops , hooks = hooks , eval_interval_secs = 60 , timeout = timeout_secs )