parameters: (self)
docstring: Train the model.
docstring_summary: Train the model.
docstring_tokens: Train the model .
function: def train(self):
      """Train the model."""
      opts = self._options
  
      initial_epoch, initial_words = self._session.run([self._epoch, self._words])
  
      workers = []
      for _ in xrange(opts.concurrent_steps):
        t = threading.Thread(target=self._train_thread_body)
        t.start()
        workers.append(t)
  
      last_words, last_time = initial_words, time.time()
      while True:
        time.sleep(5)  # Reports our progress once a while.
        (epoch, step, words, lr) = self._session.run(
            [self._epoch, self.global_step, self._words, self._lr])
        now = time.time()
        last_words, last_time, rate = words, now, (words - last_words) / (
            now - last_time)
        print("Epoch %4d Step %8d: lr = %5.3f words/sec = %8.0f\r" % (epoch, step,
                                                                      lr, rate),
              end="")
        sys.stdout.flush()
        if epoch != initial_epoch:
          break
  
      for t in workers:
        t.join()
function_tokens: def train ( self ) : opts = self . _options initial_epoch , initial_words = self . _session . run ( [ self . _epoch , self . _words ] ) workers = [ ] for _ in xrange ( opts . concurrent_steps ) : t = threading . Thread ( target = self . _train_thread_body ) t . start ( ) workers . append ( t ) last_words , last_time = initial_words , time . time ( ) while True : time . sleep ( 5 ) # Reports our progress once a while. ( epoch , step , words , lr ) = self . _session . run ( [ self . _epoch , self . global_step , self . _words , self . _lr ] ) now = time . time ( ) last_words , last_time , rate = words , now , ( words - last_words ) / ( now - last_time ) print ( "Epoch %4d Step %8d: lr = %5.3f words/sec = %8.0f\r" % ( epoch , step , lr , rate ) , end = "" ) sys . stdout . flush ( ) if epoch != initial_epoch : break for t in workers : t . join ( )