def step(self, x, states): h, [h, c] = super(AttentionLSTM, self).step(x, states) attention = states[4] m = K.tanh(K.dot(h, self.U_a) + attention + self.b_a) s = K.exp(K.dot(m, self.U_s) + self.b_s) h = h * s return h, [h, c]
def get_constants(self, x): constants = super(AttentionLSTM, self).get_constants(x) constants.append(K.dot(self.attentionvec, self.U_m) + self.b_m) return constants