LSTMwith its shapes on

V · Explorer

Shape explorer

Change the four sizes. The equations, the counts and the blocks below update as you go. This is the modern no-peephole teaching cell, not a verbatim historical model. The rules do not change, only the numbers beneath the symbols.

The cell at these sizes

Named axes: D is the recurrent source, R the distinct projection destination, |R|=|D|. K=G·R has 4D entries; J=E+D. Unpack unfuses K→G×R, selects each gate, then explicitly renames R→D. Its backward adjoint packs in reverse, D→R and G×R→K. Number-only labels substitute sizes from this ledger; equal numbers never identify different axes.

Parameters

Parameters3,935,23215.7 MB
…of which W, U, b1,572,864 + 2,359,296 + 3,072
Input X1,048,5764.2 MB
Output H1,572,8646.3 MB
Activations kept for BPTT (≈ T·B·6D)9,437,18437.7 MB
Matrix-product work per step, 2·B·4D·(E+D)125.8 MFLOP
…per whole batch sequence (×T), forward only16.11 GFLOP

Memory is for 32-bit floats; the BPTT estimate excludes inputs, workspaces, gradients and optimizer storage. FLOPs count a multiply and an add as two. Gate outputs are sigmoid for i,f,o and tanh for g, as on the forward page.

The blocks

This is the fused product, z = [x ‖ h] · [W ; U], drawn to scale as a Falk diagram. Each entry of z is the row of [x ‖ h] to its left, multiplied along the column of [W ; U] above it. The edges that are summed away are shaded the same: E against E, D against D. The batch edge is drawn thicker than true scale so that it stays visible (dashed outline).

4D = 3072W 512×3072U 768×3072x: E=512h: D=768Bifgoz: 16×3072, split along G into 4 × (16×768)E+D= 1280

The output of the whole sequence, H, is a block of 16 × 128 × 768 = 1,572,864 numbers:

D = 768B = 16T = 128