Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Tensorflow Tfjs Recurrent Neural Networks

From Leeroopedia


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:

ft=σ(Wf[ht1,xt]+bf)(forget gate)

it=σ(Wi[ht1,xt]+bi)(input gate)

C~t=tanh(WC[ht1,xt]+bC)(candidate)

Ct=ftCt1+itC~t(cell state)

ot=σ(Wo[ht1,xt]+bo)(output gate)

ht=ottanh(Ct)(hidden state)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment