(path, instantiate_sess=True)
return wmodel
Builds graph, loads checkpoint, and returns wrapped model.
Builds graph, loads checkpoint, and returns wrapped model.
Builds graph loads checkpoint and returns wrapped model .
def load_checkpoint(path, instantiate_sess=True):
  """Builds graph, loads checkpoint, and returns wrapped model."""
  tf.logging.info('Loading checkpoint from %s', path)
  hparams = lib_hparams.load_hparams(path)
  model = build_graph(is_training=False, hparams=hparams)
  wmodel = lib_tfutil.WrappedModel(model, model.loss.graph, hparams)
  if not instantiate_sess:
    return wmodel
  with wmodel.graph.as_default():
    wmodel.sess = tf.Session()
    saver = tf.train.Saver()
    tf.logging.info('loading checkpoint %s', path)
    chkpt_path = os.path.join(path, 'best_model.ckpt')
    saver.restore(wmodel.sess, chkpt_path)
  return wmodel
def load_checkpoint ( path , instantiate_sess = True ) : tf . logging . info ( 'Loading checkpoint from %s' , path ) hparams = lib_hparams . load_hparams ( path ) model = build_graph ( is_training = False , hparams = hparams ) wmodel = lib_tfutil . WrappedModel ( model , model . loss . graph , hparams ) if not instantiate_sess : return wmodel with wmodel . graph . as_default ( ) : wmodel . sess = tf . Session ( ) saver = tf . train . Saver ( ) tf . logging . info ( 'loading checkpoint %s' , path ) chkpt_path = os . path . join ( path , 'best_model.ckpt' ) saver . restore ( wmodel . sess , chkpt_path ) return wmodel