Recurrent network

Recurrent · pattern · Token sequence, Audio, Time series → Token sequence, Scores

A recurrent layer carries state across time steps; a dense head turns each step’s state into a prediction.

Also called RNN, LSTM network, Stacked LSTM

Figure 1. The Recurrent network as a schematic: the parts it is built from and how data flows between them. Select a part to read about it.

What it does

A recurrent network reads a sequence one step at a time. One or more stacked recurrent layers (LSTM or GRU) update a hidden state from the current input and the previous state, and a dense layer reads the state at every step. For generation the output is a distribution over the next event; a sample is drawn and fed back in as the next input, so the model writes a sequence of any length. For streaming detection the output is a score per frame.

Formula

ht = LSTM(xt, ht−1)p(xt+1) = softmax(W ht + b)xt+1 ~ p(xt+1) (generation feeds the sample back)

Shapes and parameters

Shapes
Inputs [T, N, I], states [N, H] per layer, outputs [T, N, K].
Parameters
Each LSTM layer costs about 4H × (I + H); the head H × K + K. MelodyRNN’s two 512-unit layers and 38-way head total about 3.25 million.
Used for
SketchRNN drawings, MelodyRNN melodies, Silero voice activity detection, older language and speech models.

Figure 2. A real recurrent network in WeightSpace: Continue a melody, drawn from the file the app runs. Open a module to see the parts inside.

In WeightSpace

SketchRNN and MelodyRNN are edited through the biases of the dense head that reads the LSTM state: pen states for drawings, specific notes and note-off events for melodies. Because the head runs at every step, a small bias change accumulates over the whole generated sequence.