VI · Translate
Translating papers
Primary equations on the left, a named-shape teaching presentation on the right. Left-hand displays normalise typesetting and select equations; they are not facsimiles. Batching, renaming, biases added by us and modern architectural variants are identified explicitly.
1 · Hochreiter & Schmidhuber, 1997
Checked against Long Short-Term Memory, §4, printed pp. 6–8 (the forward definitions are unnumbered); CEC: §3.2, pp. 5–6; truncated learning: Appendix A.1. The simplified presentation below takes one cell per block. The paper also describes S cells sharing input/output gates (§4, p. 8).
Let N denote the full set of source units u and C the selected memory cells. These are distinct coordinate sets even if their cardinalities happened to agree. The original g and h are squash/scale functions; h here is a function, not our modern hidden-state tensor.
The output gate is formed analogously to the input gate. There is no learned forget gate on the old state. The isolated self-connection has weight one and identity activation: that is the original CEC, not a proof that all gradients everywhere in the network are constant. The original algorithm truncates other routes; our modern BPTT page does not. The §4 “Learning” paragraph calls the method a truncated variant of RTRL. The absence of a batch axis in this presentation is not a claim that batching is impossible.
2 · Graves, 2013, with diagonal peepholes
Checked against §2.1, Eqs. 7–11; diagonal W_c matrices are specified in the paragraph immediately after Eq. 11. Batching, row-oriented weights and q/v intermediates on the right are ours.
For each gate/candidate a∈{i,f,c,o}, declare Wᵃ:E×R, Uᵃ:D×R, bᵃ:(B)×R, vᵃ:B×R and qᵃ:B×D. Here |R|=|D|=768 but R≠D. Define the shared affine family and its explicit coordinate rename:
Each peephole pᵃ has stored shape D and effective shape (B)×D. It is diagonal and has only D parameters, not D².
The output peephole uses the current c_t, so it waits for the cell update. The affine projections themselves may still be fused. At E=512,D=768, diagonal peepholes add 3D=2304 parameters: 4D(E+D+1)+3D=3,937,536. Our main forward/backward pages omit these peepholes and are labelled accordingly.
3 · Cho et al., 2014: reset before projection
Checked against §2.3, Eqs. 5–8 (shown in order 5,6,8,7). Biases are not displayed in the original equations. On the right we add a bias per block and choose φ=tanh as in the encoder specification, Appendix A.
Use the same D/R distinction and affine family for a∈{r,z}. All gates, candidates and hidden states below have B×D. Wⁿ:E×R, Uⁿ:D×R and bⁿ:(B)×R are declared for the candidate.
PyTorch’s nn.GRU “Note” explicitly documents a different candidate: reset is applied after the recurrent projection. In our axes its candidate is:
Both biases are (B)×R before renaming. The reset-after candidate allows all three recurrent affine products to be computed together; reset-before generally cannot fuse the candidate with the other two. These are different functions, not interchangeable notation. There is a further historical nuance: Cho’s Appendix A.1.1 decoder already writes the reset gate after the recurrent projection (and adds context). Our comparison is specifically with §2.3 Eq. 8 and Appendix A.1’s encoder, not a claim that every formula in the paper uses reset-before. Counts at E=512,D=768: 3D(E+D+1)=2,951,424 with our added single bias; 3D(E+D+2)=2,953,728 for PyTorch’s two biases. The source equations with no displayed biases have 3D(E+D)=2,949,120 matrix parameters.
4 · Vaswani et al., 2017: attention
Checked against §3.2.1, Eq. 1; projections are in §3.2.2’s unnumbered multi-head equations, and causal masking is in §3.2.3. Our numerical example (model width 768, 12 heads) is not the paper’s base configuration (512, 8 heads, head width 64).
For one head, declare B=16, query positions T=128, key/value positions T′=128, model width M=768, key width F=64, and value width L=64. T≠T′ and F≠L despite their equal cardinalities. The three weights are W^Q:M×F, W^K:M×F, W^V:M×L; they have 3·768·64=147,456 entries without biases.
The causal mask is zero at allowed keys and −∞ at disallowed keys; omit it for unrestricted encoder self-attention. Every query must have at least one allowed key. B is shared and retained during the F contraction. T′ is the normalised/reduced key axis; no transpose ambiguity remains. Chiang–Rush–Barak already use this example in §1 and give the named-axis attention function in §4.3, Eqs. 9–10.
For 12 heads add N=12 to Q,K,V and the corresponding weights. Each head retains its own F/L coordinates. The output projection uses distinct destination model coordinates M′:
The three input projections total 1,769,472 parameters, and W^O adds 589,824, excluding all biases. Explicit renaming permits a later residual sum with X without identifying unrelated axes inside a dense map.