GRUCell is distinct from the RNN subclass GRU 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 GRU 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 GRUCell 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 `gruCell`'s number of units.
To create an RNN consisting of only oneGRUCell, use the
tf.layers.gru.
Cell class for
GRU.GRUCellis distinct from theRNNsubclassGRUin that itsapplymethod takes the input data of only a single time step and returns the cell's output at the time step, whileGRUtakes the input data over a number of time steps. For example:Instance(s) of
GRUCellcan be used to constructRNNlayers. The most typical use of this workflow is to combine a number of cells into a stacked RNN cell (i.e.,StackedRNNCellinternally) and use it to create an RNN. For example:To create an
RNNconsisting of only oneGRUCell, use thetf.layers.gru.