Ejemplo n.º 1
0
 def call(self, outputs, sequence_length=None, axis=1):
     x = melt.top_k_pooling(outputs, self.top_k, sequence_length,
                            axis).values
     x = tf.reduce_sum(x * self.w, -1)
     return x
Ejemplo n.º 2
0
 def call(self, outputs, sequence_length=None, axis=1):
     x = melt.top_k_pooling(outputs, self.top_k, sequence_length,
                            axis).values
     x = tf.transpose(x, [0, 2, 1])
     x = self.att(x)
     return x
Ejemplo n.º 3
0
 def call(self, outputs, sequence_length=None, axis=1):
     x = melt.top_k_pooling(outputs, self.top_k, sequence_length,
                            axis).values
     return tf.reshape(x, [-1, melt.get_shape(outputs, -1) * self.top_k])