INNER CODE UNIT · Python
get_feed_data
ematvey/hierarchical-attention-networks · HAN_model.py:158
def get_feed_data(self, x, y=None, class_weights=None, is_training=True):
x_m, doc_sizes, sent_sizes = data_util.batch(x)
fd = {
self.inputs: x_m,
self.sentence_lengths: doc_sizes,
self.word_lengths: sent_sizes,
}
if y is not None:
fd[self.labels] = y
if class_weights is not None:
fd[self.sample_weights] = [class_weights[yy] for yy in y]
else:
fd[self.sample_weights] = np.ones(shape=[len(x_m)], dtype=np.float32)
fd[self.is_training] = is_training
return fd
if __name__ == '__main__':