(self, example_list, hps)
Initializes the following:
        self.enc_batch:
          numpy array of shape (batch_size, <=max_enc_steps) containing integer ids (all OOVs represented by UNK id), padded to length of longest sequence in the batch
        self.enc_lens:
          numpy array of shape (batch_size) containing integers. The (truncated) length of each encoder input sequence (pre-padding).
        self.enc_padding_mask:
          numpy array of shape (batch_size, <=max_enc_steps), containing 1s and 0s. 1s correspond to real tokens in enc_batch and target_batch; 0s correspond to padding.

      If hps.pointer_gen, additionally initializes the following:
        self.max_art_oovs:
          maximum number of in-article OOVs in the batch
        self.art_oovs:
          list of list of in-article OOVs (strings), for each example in the batch
        self.enc_batch_extend_vocab:
          Same as self.enc_batch, but in-article OOVs are represented by their temporary article OOV number.
Initializes the following:
        self.enc_batch:
          numpy array of shape (batch_size, <=max_enc_steps) containing integer ids (all OOVs represented by UNK id), padded to length of longest sequence in the batch
        self.enc_lens:
          numpy array of shape (batch_size) containing integers. The (truncated) length of each encoder input sequence (pre-padding).
        self.enc_padding_mask:
          numpy array of shape (batch_size, <=max_enc_steps), containing 1s and 0s. 1s correspond to real tokens in enc_batch and target_batch; 0s correspond to padding.
Initializes the following : self . enc_batch : numpy array of shape ( batch_size < = max_enc_steps ) containing integer ids ( all OOVs represented by UNK id ) padded to length of longest sequence in the batch self . enc_lens : numpy array of shape ( batch_size ) containing integers . The ( truncated ) length of each encoder input sequence ( pre - padding ) . self . enc_padding_mask : numpy array of shape ( batch_size < = max_enc_steps ) containing 1s and 0s . 1s correspond to real tokens in enc_batch and target_batch ; 0s correspond to padding .
def init_encoder_seq(self, example_list, hps):
    """Initializes the following:
        self.enc_batch:
          numpy array of shape (batch_size, <=max_enc_steps) containing integer ids (all OOVs represented by UNK id), padded to length of longest sequence in the batch
        self.enc_lens:
          numpy array of shape (batch_size) containing integers. The (truncated) length of each encoder input sequence (pre-padding).
        self.enc_padding_mask:
          numpy array of shape (batch_size, <=max_enc_steps), containing 1s and 0s. 1s correspond to real tokens in enc_batch and target_batch; 0s correspond to padding.

      If hps.pointer_gen, additionally initializes the following:
        self.max_art_oovs:
          maximum number of in-article OOVs in the batch
        self.art_oovs:
          list of list of in-article OOVs (strings), for each example in the batch
        self.enc_batch_extend_vocab:
          Same as self.enc_batch, but in-article OOVs are represented by their temporary article OOV number.
    """
    # Determine the maximum length of the encoder input sequence in this batch
    max_enc_seq_len = max([ex.enc_len for ex in example_list])

    # Pad the encoder input sequences up to the length of the longest sequence
    for ex in example_list:
      ex.pad_encoder_input(max_enc_seq_len, self.pad_id)

    # Initialize the numpy arrays
    # Note: our enc_batch can have different length (second dimension) for each batch because we use dynamic_rnn for the encoder.
    self.enc_batch = np.zeros((hps.batch_size, max_enc_seq_len), dtype=np.int32)
    self.enc_lens = np.zeros((hps.batch_size), dtype=np.int32)
    self.enc_padding_mask = np.zeros((hps.batch_size, max_enc_seq_len), dtype=np.float32)

    # Fill in the numpy arrays
    for i, ex in enumerate(example_list):
      self.enc_batch[i, :] = ex.enc_input[:]
      self.enc_lens[i] = ex.enc_len
      for j in xrange(ex.enc_len):
        self.enc_padding_mask[i][j] = 1

    # For pointer-generator mode, need to store some extra info
    if hps.pointer_gen:
      # Determine the max number of in-article OOVs in this batch
      self.max_art_oovs = max([len(ex.article_oovs) for ex in example_list])
      # Store the in-article OOVs themselves
      self.art_oovs = [ex.article_oovs for ex in example_list]
      # Store the version of the enc_batch that uses the article OOV ids
      self.enc_batch_extend_vocab = np.zeros((hps.batch_size, max_enc_seq_len), dtype=np.int32)
      for i, ex in enumerate(example_list):
        self.enc_batch_extend_vocab[i, :] = ex.enc_input_extend_vocab[:]
def init_encoder_seq ( self , example_list , hps ) : # Determine the maximum length of the encoder input sequence in this batch max_enc_seq_len = max ( [ ex . enc_len for ex in example_list ] ) # Pad the encoder input sequences up to the length of the longest sequence for ex in example_list : ex . pad_encoder_input ( max_enc_seq_len , self . pad_id ) # Initialize the numpy arrays # Note: our enc_batch can have different length (second dimension) for each batch because we use dynamic_rnn for the encoder. self . enc_batch = np . zeros ( ( hps . batch_size , max_enc_seq_len ) , dtype = np . int32 ) self . enc_lens = np . zeros ( ( hps . batch_size ) , dtype = np . int32 ) self . enc_padding_mask = np . zeros ( ( hps . batch_size , max_enc_seq_len ) , dtype = np . float32 ) # Fill in the numpy arrays for i , ex in enumerate ( example_list ) : self . enc_batch [ i , : ] = ex . enc_input [ : ] self . enc_lens [ i ] = ex . enc_len for j in xrange ( ex . enc_len ) : self . enc_padding_mask [ i ] [ j ] = 1 # For pointer-generator mode, need to store some extra info if hps . pointer_gen : # Determine the max number of in-article OOVs in this batch self . max_art_oovs = max ( [ len ( ex . article_oovs ) for ex in example_list ] ) # Store the in-article OOVs themselves self . art_oovs = [ ex . article_oovs for ex in example_list ] # Store the version of the enc_batch that uses the article OOV ids self . enc_batch_extend_vocab = np . zeros ( ( hps . batch_size , max_enc_seq_len ) , dtype = np . int32 ) for i , ex in enumerate ( example_list ) : self . enc_batch_extend_vocab [ i , : ] = ex . enc_input_extend_vocab [ : ]