def __call__(self, inputs, state, scope=None):
with tf.variable_scope(self.scope):
c, h = state
h = dropout(h, self.keep_recurrent_probs, self.is_train)
mat = _compute_gates(inputs, h, self.num_units, self.forget_bias,
self.kernel_initializer, self.recurrent_initializer, True)
i, j, f, o = tf.split(value=mat, num_or_size_splits=4, axis=1)
new_c = (c * self.recurrent_activation(f) + self.recurrent_activation(i) *
self.activation(j))
new_h = self.activation(new_c) * self.recurrent_activation(o)
new_state = LSTMStateTuple(new_c, new_h)
return new_h, new_state
评论列表
文章目录