Principle:Tensorflow Tfjs Recurrent Neural Networks
| Knowledge Sources | |
|---|---|
| Domains | Deep_Learning, Sequence_Modeling, Neural_Network_Architecture |
| Last Updated | 2026-02-10 06:00 GMT |
Overview
Neural network architecture that maintains hidden state across time steps, enabling sequential pattern recognition and temporal dependency modeling.
Description
Recurrent Neural Networks (RNNs) process sequential data by maintaining a hidden state vector that is updated at each time step, allowing information to persist across the sequence. TensorFlow.js implements three standard RNN variants:
- SimpleRNN: Basic recurrent unit with a single tanh activation
- GRU (Gated Recurrent Unit): Uses update and reset gates to control information flow, mitigating the vanishing gradient problem
- LSTM (Long Short-Term Memory): Uses input, forget, and output gates with a separate cell state for long-range dependency capture
Each variant consists of a Cell class (single step computation) and a Layer class (unrolling across time steps). The base RNN class provides the unrolling logic and supports returnSequences, returnState, goBackwards, and stateful modes.
Usage
Use recurrent layers for tasks involving temporal or sequential data: time series forecasting, natural language processing (before Transformer era), speech recognition, and music generation. LSTM is the default choice for most tasks; GRU offers similar performance with fewer parameters.
Theoretical Basis
LSTM equations: