parameters: (self,
                         input_fn,
                         name,
                         delay_secs,
                         throttle_delay_secs,
                         evaluate_checkpoint_only_once=True,
                         continuous_eval_predicate_fn=None)
docstring: Run continuous eval.
  
      Runs infinite eval on the evaluation data set. This function starts
      evaluating after `delay_secs` seconds and then runs no more than one
      evaluation (with `self._eval_steps` steps each time) per
      `throttle_delay_secs`. If `train_steps` is not None, will return after
      global_step reaches `train_steps`.
  
      Args:
        input_fn: The input to use for this eval.
        name: A string appended to the folder name of evaluation results.
        delay_secs: Start evaluating after this many seconds. If None, defaults to
          self._eval_delay_secs.
        throttle_delay_secs: Do not re-evaluate unless the last evaluation was
          started at least this many seconds ago. If None, defaults to
          self._continuous_eval_throttle_secs.
        evaluate_checkpoint_only_once: Whether to skip evaluation of checkpoints
          that have already been evaluated. Default is `True`.
        continuous_eval_predicate_fn: A predicate function determining whether to
          continue eval after each iteration. `predicate_fn` takes the evaluation
          results as arguments. At the beginning of evaluation, the passed eval
          results will be None so it's expected that the predicate function
          handles that gracefully. When `predicate_fn` is not specified,
          continuous eval will run in an infinite loop (if `train_steps` is None)
          or exit once global step reaches `train_steps`.
  
      Raises:
        ValueError: if `continuous_eval_predicate_fn` is neither None nor
          callable.
docstring_summary: Run continuous eval.
docstring_tokens: Run continuous eval .
function: def _continuous_eval(self,
                         input_fn,
                         name,
                         delay_secs,
                         throttle_delay_secs,
                         evaluate_checkpoint_only_once=True,
                         continuous_eval_predicate_fn=None):
      """Run continuous eval.
  
      Runs infinite eval on the evaluation data set. This function starts
      evaluating after `delay_secs` seconds and then runs no more than one
      evaluation (with `self._eval_steps` steps each time) per
      `throttle_delay_secs`. If `train_steps` is not None, will return after
      global_step reaches `train_steps`.
  
      Args:
        input_fn: The input to use for this eval.
        name: A string appended to the folder name of evaluation results.
        delay_secs: Start evaluating after this many seconds. If None, defaults to
          self._eval_delay_secs.
        throttle_delay_secs: Do not re-evaluate unless the last evaluation was
          started at least this many seconds ago. If None, defaults to
          self._continuous_eval_throttle_secs.
        evaluate_checkpoint_only_once: Whether to skip evaluation of checkpoints
          that have already been evaluated. Default is `True`.
        continuous_eval_predicate_fn: A predicate function determining whether to
          continue eval after each iteration. `predicate_fn` takes the evaluation
          results as arguments. At the beginning of evaluation, the passed eval
          results will be None so it's expected that the predicate function
          handles that gracefully. When `predicate_fn` is not specified,
          continuous eval will run in an infinite loop (if `train_steps` is None)
          or exit once global step reaches `train_steps`.
  
      Raises:
        ValueError: if `continuous_eval_predicate_fn` is neither None nor
          callable.
      """
      if (continuous_eval_predicate_fn is not None and
          not callable(continuous_eval_predicate_fn)):
        raise ValueError(
            "`continuous_eval_predicate_fn` must be a callable, or None.")
  
      if delay_secs is None:
        delay_secs = self._eval_delay_secs
      if throttle_delay_secs is None:
        throttle_delay_secs = self._continuous_eval_throttle_secs
  
      if delay_secs:
        logging.info("Waiting %f secs before starting eval.", delay_secs)
        time.sleep(delay_secs)
  
      previous_path = None
      eval_result = None
      last_warning_time = 0
      while (not continuous_eval_predicate_fn or
             continuous_eval_predicate_fn(eval_result)):
        # Exit if we have already reached number of steps to train.
        if self._has_training_stopped(eval_result):
          logging.info("Exiting continuous eval, global_step=%s >= "
                       "train_step=%s",
                       eval_result[ops.GraphKeys.GLOBAL_STEP],
                       self._train_steps)
          return
  
        start = time.time()
  
        error_msg = None
        latest_path = saver.latest_checkpoint(self._estimator.model_dir)
        if not latest_path:
          error_msg = ("Estimator is not fitted yet. "
                       "Will start an evaluation when a checkpoint is ready.")
        elif evaluate_checkpoint_only_once and latest_path == previous_path:
          error_msg = "No new checkpoint ready for evaluation."
  
        if error_msg:
          # Print warning message every 10 mins.
          eval_result = {}
          if time.time() - last_warning_time > 600:
            logging.warning(error_msg)
            last_warning_time = time.time()
        else:
          eval_result = self._call_evaluate(input_fn=input_fn,
                                            steps=self._eval_steps,
                                            metrics=self._eval_metrics,
                                            name=name,
                                            checkpoint_path=latest_path,
                                            hooks=self._eval_hooks)
          # Ensure eval result is not None for next round of evaluation.
          if not eval_result:
            eval_result = {}
  
          self._maybe_export(eval_result, checkpoint_path=latest_path)
  
          # Clear warning timer and update last evaluated checkpoint
          last_warning_time = 0
          previous_path = latest_path
  
        duration = time.time() - start
        if duration < throttle_delay_secs:
          difference = throttle_delay_secs - duration
          logging.info("Waiting %f secs before starting next eval run.",
                       difference)
          time.sleep(difference)
function_tokens: def _continuous_eval ( self , input_fn , name , delay_secs , throttle_delay_secs , evaluate_checkpoint_only_once = True , continuous_eval_predicate_fn = None ) : if ( continuous_eval_predicate_fn is not None and not callable ( continuous_eval_predicate_fn ) ) : raise ValueError ( "`continuous_eval_predicate_fn` must be a callable, or None." ) if delay_secs is None : delay_secs = self . _eval_delay_secs if throttle_delay_secs is None : throttle_delay_secs = self . _continuous_eval_throttle_secs if delay_secs : logging . info ( "Waiting %f secs before starting eval." , delay_secs ) time . sleep ( delay_secs ) previous_path = None eval_result = None last_warning_time = 0 while ( not continuous_eval_predicate_fn or continuous_eval_predicate_fn ( eval_result ) ) : # Exit if we have already reached number of steps to train. if self . _has_training_stopped ( eval_result ) : logging . info ( "Exiting continuous eval, global_step=%s >= " "train_step=%s" , eval_result [ ops . GraphKeys . GLOBAL_STEP ] , self . _train_steps ) return start = time . time ( ) error_msg = None latest_path = saver . latest_checkpoint ( self . _estimator . model_dir ) if not latest_path : error_msg = ( "Estimator is not fitted yet. " "Will start an evaluation when a checkpoint is ready." ) elif evaluate_checkpoint_only_once and latest_path == previous_path : error_msg = "No new checkpoint ready for evaluation." if error_msg : # Print warning message every 10 mins. eval_result = { } if time . time ( ) - last_warning_time > 600 : logging . warning ( error_msg ) last_warning_time = time . time ( ) else : eval_result = self . _call_evaluate ( input_fn = input_fn , steps = self . _eval_steps , metrics = self . _eval_metrics , name = name , checkpoint_path = latest_path , hooks = self . _eval_hooks ) # Ensure eval result is not None for next round of evaluation. if not eval_result : eval_result = { } self . _maybe_export ( eval_result , checkpoint_path = latest_path ) # Clear warning timer and update last evaluated checkpoint last_warning_time = 0 previous_path = latest_path duration = time . time ( ) - start if duration < throttle_delay_secs : difference = throttle_delay_secs - duration logging . info ( "Waiting %f secs before starting next eval run." , difference ) time . sleep ( difference )