def __call__(self, inputs, state, scope=None):
with vs.variable_scope(scope or type(self).__name__):
t_state = tf.transpose(state)
state_out = doRotations(t_state, self._rotations)
input_out = linearTransformWithBias([inputs],
self._num_units, bias=False, scope=scope)
state_out = tf.transpose(state_out)
gate = linearTransformWithBias([inputs, state], self._num_units, True, scope='GateLinearTransfrom')
gate = tf.nn.sigmoid(gate, name='GateSigmoid')
bias = vs.get_variable(
"Bias", [self._num_units],
dtype=tf.float32,
initializer=init_ops.constant_initializer(dtype=tf.float32))
input_gate = tf.add(-1.0, gate)
# print(input_gate)
output = state * gate + input_gate * tf.abs(state_out + input_out + bias)
return output, output
评论列表
文章目录