(output_dir, model, weights_file=None)
return trainer_state
Returns a TrainerState instance loaded from the given `output_dir`.
Returns a TrainerState instance loaded from the given `output_dir`.
Returns a TrainerState instance loaded from the given output_dir .
def load_trainer_state(output_dir, model, weights_file=None):
  """Returns a TrainerState instance loaded from the given `output_dir`."""
  if weights_file is None:
    weights_file = os.path.join(output_dir, 'model.pkl.gz')
    if not tf.io.gfile.exists(weights_file):
      return TrainerState(step=None, opt_state=None,
                          history=trax_history.History(), model_state=None)
  elif not tf.io.gfile.exists(weights_file):
    raise ValueError('File not found: %s' % weights_file)

  trainer_state_dict = training.unpickle_from_file(weights_file, gzip=True)
  trainer_state = trainer_state_from_dict(trainer_state_dict, model)
  log('Model loaded from %s at step %d' % (weights_file, trainer_state.step))
  logging.debug('From loaded model : history = %s', trainer_state.history)
  return trainer_state
def load_trainer_state ( output_dir , model , weights_file = None ) : if weights_file is None : weights_file = os . path . join ( output_dir , 'model.pkl.gz' ) if not tf . io . gfile . exists ( weights_file ) : return TrainerState ( step = None , opt_state = None , history = trax_history . History ( ) , model_state = None ) elif not tf . io . gfile . exists ( weights_file ) : raise ValueError ( 'File not found: %s' % weights_file ) trainer_state_dict = training . unpickle_from_file ( weights_file , gzip = True ) trainer_state = trainer_state_from_dict ( trainer_state_dict , model ) log ( 'Model loaded from %s at step %d' % ( weights_file , trainer_state . step ) ) logging . debug ( 'From loaded model : history = %s' , trainer_state . history ) return trainer_state