SimpleRNNCell is distinct from the RNN subclass SimpleRNN in that its
apply method takes the input data of only a single time step and returns
the cell's output at the time step, while SimpleRNN takes the input data
over a number of time steps. For example:
console.log(JSON.stringify(output.shape)); // [null, 10]: This is the cell's output at a single time step. The 1st // dimension is the unknown batch size.
Instance(s) of SimpleRNNCell can be used to construct RNN layers. The
most typical use of this workflow is to combine a number of cells into a
stacked RNN cell (i.e., StackedRNNCell internally) and use it to create an
RNN. For example:
// Create an input with 10 time steps and a length-20 vector at each step. constinput = tf.input({shape: [10, 20]}); constoutput = rnn.apply(input);
console.log(JSON.stringify(output.shape)); // [null, 10, 8]: 1st dimension is unknown batch size; 2nd dimension is the // same as the sequence length of `input`, due to `returnSequences`: `true`; // 3rd dimension is the last `SimpleRNNCell`'s number of units.
To create an RNN consisting of only oneSimpleRNNCell, use the
tf.layers.simpleRNN.
Cell class for
SimpleRNN
.SimpleRNNCell
is distinct from theRNN
subclassSimpleRNN
in that itsapply
method takes the input data of only a single time step and returns the cell's output at the time step, whileSimpleRNN
takes the input data over a number of time steps. For example:Instance(s) of
SimpleRNNCell
can be used to constructRNN
layers. The most typical use of this workflow is to combine a number of cells into a stacked RNN cell (i.e.,StackedRNNCell
internally) and use it to create an RNN. For example:To create an
RNN
consisting of only oneSimpleRNNCell
, use thetf.layers.simpleRNN
.