def _run()

in tensorflow_fold/blocks/plan.py [0:0]


  def _run(self, supervisor, session):
    batches = (  # generates (size, feed_dict) pairs
        (len(batch), self.compiler.build_feed_dict(batch))
        for batch in util.group_by_batches(self.examples, self.batch_size))
    if self.eval_interval_secs:
      gen_batches = util.epochs(batches, shuffle=False)  # memoize batches
      max_reported_step = 0
      # Should eval for the final measurement even if _should_stop is true.
      while not (self._should_stop(supervisor) and max_reported_step > 0):
        start_time = time.time()
        if self._restore(supervisor, session):
          step = tf.train.global_step(session, self.global_step)
          if step > max_reported_step:
            max_reported_step = step
            results = self._eval_batches(
                supervisor, session, next(gen_batches), step)
            self._report_loss_and_save_best(supervisor, session, step, *results)
            if self._should_stop(supervisor): break
          else:
            self.log_and_print('not running eval because step=%s' % step)
        sleep_time = self.eval_interval_secs - (time.time() - start_time)
        if sleep_time > 0: time.sleep(sleep_time)
    elif self._restore(supervisor, session):
      step = tf.train.global_step(session, self.global_step)
      results = self._eval_batches(supervisor, session, batches, step)
      if results[0] is not None:
        self._report_loss_and_save_best(supervisor, session, step, *results)
    self.report_done()