예제 #1
0
    def __call__(self, inputs, state, scope = None):
        with tf.variable_scope(scope or type(self).__name__):
            with tf.variable_scope("Gates"):
                reset, update = tf.split(
                    1,
                    2,
                    linear(
                        [inputs, states], 
                        2 * self._num_units,
                        bias = True,
                        bias_start = 1.0
                    )
                )
                reset, update = tf.sigmoid(reset), tf.sigmoid(update)

            with tf.variable_scope("Candidate"):
                candidate = linear(
                    [inputs, reset * state],
                    self._num_units,
                    bias = True
                )
                candidate = tf.tanh(candidate)

            new_state = update * state + (1 - update) * candidate

            return new_state, new_state
예제 #2
0
    def __call__(self, inputs, state, scope = None):
        with tf.variable_scope(scope or type(self).__name__):
            c, h = tf.split(1, 2, state)
            concat = linear(
                [inputs, h], 
                4 * self._num_units, 
                bias = True
            )

            i, j, f, o = tf.split(1, 4, concat)

            new_c = c * tf.sigmoid(f + self._forget_bias) + tf.sigmoid(i) * tf.tanh(j)
            new_h = tf.tanh(new_c) * tf.sigmoid(o)
            new_state = tf.concat(1, [new_c, new_h])

        return new_h, new_state
예제 #3
0
 def __call__(self, inputs, state, scope = None):
     with tf.variable_scope(scope or type(self).__name__):
         output = tf.tanh(linear([inputs, state], self._num_units, bias = True))
     return output, output