INNER CODE UNIT · Python
hidden
ematvey/hierarchical-attention-networks · bn_lstm.py:44
hidden = tf.matmul(concat, W_both) + bias
i, j, f, o = tf.split(hidden, 4, axis=1)
new_c = c * tf.sigmoid(f) + tf.sigmoid(i) * tf.tanh(j)
new_h = tf.tanh(new_c) * tf.sigmoid(o)
return new_h, (new_c, new_h)
class BNLSTMCell(RNNCell):
"""Batch normalized LSTM as described in http://arxiv.org/abs/1603.09025"""
def __init__(self, num_units, training):
self.num_units = num_units
self.training = training
@property
def state_size(self):
return (self.num_units, self.num_units)