def get_feed_dict(self, inps, trgts=None): """Creates the feed_dict that is fed into training or inference network. Pads inputs and targets. Returns feed_dict and sequence_length(s) depending on training mode. """ if self.mode != 'INFER': inp_ids, sequence_lengths_1 = summarizer_model_utils.pad_sequences(inps, self.word2ind[self.pad], tail=False) feed = { self.ids_1: inp_ids, self.sequence_lengths_1: sequence_lengths_1 } if trgts is not None: trgt_ids, sequence_lengths_2 = summarizer_model_utils.pad_sequences(trgts, self.word2ind[self.pad], tail=True) feed[self.ids_2] = trgt_ids feed[self.sequence_lengths_2] = sequence_lengths_2 return feed, sequence_lengths_1, sequence_lengths_2 else: inp_ids, sequence_lengths_1 = summarizer_model_utils.pad_sequences(inps, self.word2ind[self.pad], tail=False) feed = { self.ids_1: inp_ids, self.sequence_lengths_1: sequence_lengths_1 } if trgts is not None: trgt_ids, sequence_lengths_2 = summarizer_model_utils.pad_sequences(trgts, self.word2ind[self.pad], tail=True) feed[self.sequence_lengths_2] = sequence_lengths_2 return feed, sequence_lengths_1, sequence_lengths_2 else: return feed, sequence_lengths_1
def get_feed_dict(self, inps, trgts=None): if self.mode != 'INFER': inp_ids, sequence_lengths_1 = summarizer_model_utils.pad_sequences( inps, self.word2ind[self.pad], tail=False) feed = { self.ids_1: inp_ids, self.sequence_lengths_1: sequence_lengths_1 } if trgts is not None: trgt_ids, sequence_lengths_2 = summarizer_model_utils.pad_sequences( trgts, self.word2ind[self.pad], tail=True) feed[self.ids_2] = trgt_ids feed[self.sequence_lengths_2] = sequence_lengths_2 return feed, sequence_lengths_1, sequence_lengths_2 else: inp_ids, sequence_lengths_1 = summarizer_model_utils.pad_sequences( inps, self.word2ind[self.pad], tail=False) feed = { self.ids_1: inp_ids, self.sequence_lengths_1: sequence_lengths_1 } if trgts is not None: trgt_ids, sequence_lengths_2 = summarizer_model_utils.pad_sequences( trgts, self.word2ind[self.pad], tail=True) feed[self.sequence_lengths_2] = sequence_lengths_2 return feed, sequence_lengths_1, sequence_lengths_2 else: return feed, sequence_lengths_1