1
$\begingroup$

Two types of RNN can be used:

Type1: The output is being used as state

h(t) = g(W1.x(t) + W2.h(t-1) + b1)

Type2: There is a state in addition to the output

a(t) = g(W1.x(t) + W2.a(t-1) + b1)

h(t) = g(W3.a(t) + b2)

Which of the above mathematical structure is implemented by SimpleRNN in keras? I tried looking at the documentation, but its unclear.

Edit: The source of keras.layers.SimpleRNN suggests RNN of type 1. See the call method of SimpleRNNCell at https://github.com/keras-team/keras/blob/master/keras/layers/recurrent.py

$\endgroup$

2 Answers 2

1
$\begingroup$

The documentation already linked says it all:

"""Fully-connected RNN where the output is to be fed back to input.

So simply said, the output of your previous step is used as the recurrent input for the next step. Therefore you are dealing with the first type you described.

$\endgroup$
0
$\begingroup$

The documentation for the SimpleRnn defines the argument:

return_state: Boolean. Whether to return the last state in addition to the output.

Which would imply that states and outputs are regarded separately.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.