(self, model, batcher, vocab)
Initialize decoder.

    Args:
      model: a Seq2SeqAttentionModel object.
      batcher: a Batcher object.
      vocab: Vocabulary object
Initialize decoder.
Initialize decoder .
def __init__(self, model, batcher, vocab):
    """Initialize decoder.

    Args:
      model: a Seq2SeqAttentionModel object.
      batcher: a Batcher object.
      vocab: Vocabulary object
    """
    self._model = model
    self._model.build_graph()
    self._batcher = batcher
    self._vocab = vocab
    self._saver = tf.train.Saver() # we use this to load checkpoints for decoding
    self._sess = tf.Session(config=util.get_config())

    # Load an initial checkpoint to use for decoding
    ckpt_path = util.load_ckpt(self._saver, self._sess)

    if FLAGS.single_pass:
      # Make a descriptive decode directory name
      ckpt_name = "ckpt-" + ckpt_path.split('-')[-1] # this is something of the form "ckpt-123456"
      self._decode_dir = os.path.join(FLAGS.log_root, get_decode_dir_name(ckpt_name))
      if os.path.exists(self._decode_dir):
        raise Exception("single_pass decode directory %s should not already exist" % self._decode_dir)

    else: # Generic decode dir name
      self._decode_dir = os.path.join(FLAGS.log_root, "decode")

    # Make the decode dir if necessary
    if not os.path.exists(self._decode_dir): os.mkdir(self._decode_dir)

    if FLAGS.single_pass:
      # Make the dirs to contain output written in the correct format for pyrouge
      self._rouge_ref_dir = os.path.join(self._decode_dir, "reference")
      if not os.path.exists(self._rouge_ref_dir): os.mkdir(self._rouge_ref_dir)
      self._rouge_dec_dir = os.path.join(self._decode_dir, "decoded")
      if not os.path.exists(self._rouge_dec_dir): os.mkdir(self._rouge_dec_dir)
def __init__ ( self , model , batcher , vocab ) : self . _model = model self . _model . build_graph ( ) self . _batcher = batcher self . _vocab = vocab self . _saver = tf . train . Saver ( ) # we use this to load checkpoints for decoding self . _sess = tf . Session ( config = util . get_config ( ) ) # Load an initial checkpoint to use for decoding ckpt_path = util . load_ckpt ( self . _saver , self . _sess ) if FLAGS . single_pass : # Make a descriptive decode directory name ckpt_name = "ckpt-" + ckpt_path . split ( '-' ) [ - 1 ] # this is something of the form "ckpt-123456" self . _decode_dir = os . path . join ( FLAGS . log_root , get_decode_dir_name ( ckpt_name ) ) if os . path . exists ( self . _decode_dir ) : raise Exception ( "single_pass decode directory %s should not already exist" % self . _decode_dir ) else : # Generic decode dir name self . _decode_dir = os . path . join ( FLAGS . log_root , "decode" ) # Make the decode dir if necessary if not os . path . exists ( self . _decode_dir ) : os . mkdir ( self . _decode_dir ) if FLAGS . single_pass : # Make the dirs to contain output written in the correct format for pyrouge self . _rouge_ref_dir = os . path . join ( self . _decode_dir , "reference" ) if not os . path . exists ( self . _rouge_ref_dir ) : os . mkdir ( self . _rouge_ref_dir ) self . _rouge_dec_dir = os . path . join ( self . _decode_dir , "decoded" ) if not os . path . exists ( self . _rouge_dec_dir ) : os . mkdir ( self . _rouge_dec_dir )