Simple Algorithm
Deep Learning · Emergence · 26 min

Training Recurrent Networks

Teacher forcing, exposure bias, truncated backpropagation and online gradients.

Gradient descent on a recurrent network hides three decisions that the loss function never mentions: what the network is fed while it learns (the truth or its own guesses), how far back each gradient may travel, and whether the gradient is computed after the sequence ends or while it is still arriving. Each decision trades bias against variance and memory, and each has a sharp theory behind it.

What you’ll learn

  • Explain teacher forcing and exposure bias, state the T2ϵT^2\epsilon compounding-error bound for learners trained on the expert's states, and show why scheduled sampling is not a consistent estimator.
  • Write the truncated-BPTT gradient as the full gradient minus a dropped tail, bound the tail, and explain why the bias bites exactly when long memory is needed.
  • Derive real-time recurrent learning as forward-mode differentiation, with O(n4)\order{n^4} time and O(n3)\order{n^3} memory per step for a fully connected network.
  • Prove that UORO is unbiased, compare it with KF-RTRL, SnAp and e-prop, and explain why element-wise recurrence makes exact online gradients cheap.

Teacher forcing and exposure bias

An autoregressive model factorizes pθ(y∣x)=∏tpθ(yt∣y<t,x)p_{\boldsymbol\theta}(\mathbf y\mid\mathbf x)=\prod_tp_{\boldsymbol\theta}(y_t\mid y_{<t},\mathbf x), and maximum likelihood maximizes ∑tlog⁡pθ(yt∣y<t,x)\sum_t\log p_{\boldsymbol\theta}(y_t\mid y_{<t},\mathbf x) with every factor conditioned on the true prefix y<ty_{<t}. Feeding the ground truth as the next input is teacher forcing, a name introduced by Williams & Zipser (1989), who noted the technique was already in common use. Nothing is approximated: teacher forcing computes the exact gradient of the log-likelihood, and with a correct model class and unlimited data it recovers the true conditionals.

At generation time, though, the model conditions on its own samples. It has only ever been trained on prefixes drawn from the data, never on prefixes drawn from itself. Ranzato et al. (2016) named this train–test mismatch exposure bias. How badly can it hurt? Imitation learning, where a policy is trained to copy an expert's actions on the expert's own trajectories, gives a sharp answer.

The intuition is short. A first mistake happens with probability about ϵ\epsilon per step, and it can take the learner to states its training never covered, where it may keep erring for the rest of the episode. Summing up to TT remaining steps over TT possible times of the first mistake gives order T2ϵT^2\epsilon. Ross, Gordon & Bagnell recount a sequence-prediction example due to Kääriäinen (2006): a predictor with error rate ϵ\epsilon when given the correct previous output makes, in expectation, T2−1−(1−2ϵ)T+14ϵ+12\tfrac T2-\tfrac{1-(1-2\epsilon)^{T+1}}{4\epsilon}+\tfrac12 mistakes when fed its own outputs, which is Θ(T2ϵ)\Theta(T^2\epsilon) for small ϵ\epsilon. With ϵ=0.01\epsilon=0.01 and T=50T=50 that is about 9.4 mistakes, against Tϵ=0.5T\epsilon=0.5 if the errors stayed independent.

Think first Does the theorem show that teacher-forced language models must degrade quadratically with length?

No. It is a worst-case bound for a 0–1 notion of mistakes, and it is tight only on adversarially constructed problems. A language model's next-token distribution can put weight on many acceptable continuations, and a model that predicts well can often recover after an unusual token. The theorem identifies the mechanism, a shift from the data's prefixes to the model's own, not its size in any particular application.

Scheduled sampling and its critics

Scheduled sampling (Bengio, Vinyals, Jaitly & Shazeer, 2015) exposes the model to its own predictions during training. At each step it feeds the true previous token with probability ϵi\epsilon_i and a token sampled from the model's own prediction with probability 1−ϵi1-\epsilon_i, where ii counts training iterations and ϵi\epsilon_i decays from 1 toward 0 on a linear, exponential or inverse-sigmoid schedule. The target stays the true next token. It improved image captioning, parsing and speech recognition in the original experiments. Huszár (2015) then showed that the objective is improper: its optimum is not the data distribution, so the method is not a consistent estimator. The extreme case makes the problem visible.

DerivationWhat scheduled sampling converges to
  1. Lt(θ)=E(x,y)∼pdata Eu<t[−log⁡pθ(yt∣u<t,x)]\loss_t(\boldsymbol\theta)=\E_{(\mathbf x,\mathbf y)\sim p_{\text{data}}}\ \E_{\mathbf u_{<t}}\big[-\log p_{\boldsymbol\theta}(y_t\mid\mathbf u_{<t},\mathbf x)\big]

    Let u<t\mathbf u_{<t} be the prefix actually fed at step tt, a mixture of true and sampled tokens. The step-tt loss is the cross-entropy of the true yty_t under the model's prediction from u<t\mathbf u_{<t} (no gradient flows through the sampling):

  2. p⋆(yt∣u<t,x)=P(yt ∣ u<t,x)under the joint law of data and samplingp^\star(y_t\mid\mathbf u_{<t},\mathbf x)=P\big(y_t\ \big|\ \mathbf u_{<t},\mathbf x\big)\quad\text{under the joint law of data and sampling}

    With unlimited capacity, each conditional is fitted separately, and cross-entropy is minimized by the true conditional distribution of the target given what was fed:

  3. u<t⊥ ⁣ ⁣ ⁣⊥y∣x⟹p⋆(yt∣u<t,x)=pdata(yt∣x),∏tpdata(yt∣x)≠pdata(y∣x)\mathbf u_{<t}\indep\mathbf y\mid\mathbf x\quad\Longrightarrow\quad p^\star(y_t\mid\mathbf u_{<t},\mathbf x)=p_{\text{data}}(y_t\mid\mathbf x),\qquad\prod_tp_{\text{data}}(y_t\mid\mathbf x)\ne p_{\text{data}}(\mathbf y\mid\mathbf x)

    At ϵi=0\epsilon_i=0 every fed token is the model's own sample, drawn independently of the true sequence given x\mathbf x. The fed prefix then carries no information about yty_t, and the optimum is the marginal: the trained model generates every token independently, destroying all dependencies between output tokens.

  4. For 0<ϵi<10<\epsilon_i<1 the model learns the true next token given a corrupted copy of the true prefix, which is still not the conditional pdata(yt∣y<t,x)p_{\text{data}}(y_t\mid y_{<t},\mathbf x) that sampling needs. Only ϵi=1\epsilon_i=1, plain teacher forcing, is consistent.

Two other responses change the objective rather than the inputs. Sequence-level training samples whole outputs from the model and optimizes a sequence metric such as BLEU with policy gradients, so training happens on the model's own prefixes (Ranzato et al., 2016). Professor forcing (Lamb et al., 2016) adds a discriminator that sees the sequence of hidden states from a teacher-forced run and from a free-running run; the RNN is trained to make the two indistinguishable, so its dynamics stay close to the teacher-forced regime when sampling. Lamb et al. report better likelihoods on character-level Penn Treebank and sequential MNIST, and better samples over long horizons.

Check your understanding

Why is scheduled sampling not a consistent estimator, even with unlimited capacity and data?

  1. Its gradient is too noisy to converge
  2. The fed prefix may contain the model's own samples while the target is the true next token, so the optimum is the conditional of the true token given a corrupted prefix, not the data distribution's conditional
  3. It uses a decaying schedule, and any schedule introduces bias
  4. Sampling is not differentiable, so the gradient is wrong
Show the answer

B. The fed prefix may contain the model's own samples while the target is the true next token, so the optimum is the conditional of the true token given a corrupted prefix, not the data distribution's conditional

Cross-entropy is minimized by the true conditional of the target given whatever was fed. When the fed prefix is partly sampled, that conditional mixes information about the true prefix with noise; in the limit of all-sampled inputs it is the marginal pdata(yt∣x)p_{\text{data}}(y_t\mid\mathbf x). This is Huszár's (2015) improperness argument.

Long products: truncation and stabilization

Write ut=∂ℓt/∂ht\mathbf u_t=\partial\ell_t/\partial\mathbf h_t for the direct gradient of the step-tt loss, Pt,k=∂ht/∂hkP_{t,k}=\partial\mathbf h_t/\partial\mathbf h_k for the Jacobian product of Recurrent Neural Networks, and MkM_k for the immediate derivative of hk\mathbf h_k with respect to θ\boldsymbol\theta (the parameters entering at step kk alone). Truncated BPTT with a window of KK steps keeps only the recent terms.

DerivationThe bias of truncation
  1. gt⊤=∑k=1tut⊤Pt,kMk,g^t⊤=∑k=t−K+1tut⊤Pt,kMk\mathbf g_t^\top=\sum_{k=1}^{t}\mathbf u_t^\top P_{t,k}M_k,\qquad\hat{\mathbf g}_t^\top=\sum_{k=t-K+1}^{t}\mathbf u_t^\top P_{t,k}M_k

    The exact gradient of ℓt\ell_t sums over every step at which θ\boldsymbol\theta was used; truncation keeps the last KK:

  2. ∥gt−g^t∥≤∥ut∥ B∑m=Kt−1λm≤∥ut∥ B λK1−λ(λ<1)\lVert\mathbf g_t-\hat{\mathbf g}_t\rVert\le\lVert\mathbf u_t\rVert\,B\sum_{m=K}^{t-1}\lambda^{m}\le\lVert\mathbf u_t\rVert\,B\,\frac{\lambda^{K}}{1-\lambda}\qquad(\lambda<1)

    The bias is the dropped tail. With the Jacobian bound ∥Pt,k∥≤λt−k\lVert P_{t,k}\rVert\le\lambda^{t-k}, λ=γ∥W∥\lambda=\gamma\lVert W\rVert, and ∥Mk∥≤B\lVert M_k\rVert\le B, it is a geometric series:

  3. Read the bound both ways. If the dynamics contract quickly, the dropped tail is exponentially small in KK and truncation costs little, but then long-range gradient terms were negligible anyway. A network that actually carries information over more than KK steps has Jacobian products of norm near 1 over those spans; the bound no longer applies and the dropped terms are as large as the kept ones. Truncation removes precisely the signal that long-range learning needs.

Because g^t\hat{\mathbf g}_t is biased, stochastic gradient descent on it need not approach a stationary point of the true loss, and Tallec & Ollivier (2018) point out that this can even make training diverge. In practice the window is set to the dependency lengths one hopes to learn; for word-level LSTM language models, windows of a few dozen tokens were common.

The same long products explode when ∥Pt,k∥\lVert P_{t,k}\rVert grows. Gradient clipping caps the update (Pascanu, Mikolov & Bengio, 2013). A more structural fix keeps the recurrent matrix exactly norm-preserving: the unitary RNN of Arjovsky, Shah & Bengio (2016) builds WW from a product of cheap unitary factors (diagonal phases, reflections, a permutation and Fourier transforms), so every eigenvalue has modulus 1. A norm-preserving WW has its own cost: such a network cannot easily forget, and the nonlinearity's slopes still multiply in, as the widget shows.

Real-time recurrent learning

BPTT is an offline algorithm: it waits for the sequence to end and stores every state. A robot, a trading system or a model reading an endless stream needs a gradient now, with memory that does not grow with time. Real-time recurrent learning (RTRL; Williams & Zipser, 1989) gets one by running differentiation forward alongside the network, in forward mode. Write the network as ht=F(ht−1,xt;θ)\mathbf h_t=F(\mathbf h_{t-1},\mathbf x_t;\boldsymbol\theta) with pp parameters, and carry the influence matrix Jt=dht/dθ∈Rn×pJ_t=d\mathbf h_t/d\boldsymbol\theta\in\R^{n\times p}.

DerivationThe RTRL recursion and its cost
  1. Jt=Dt Jt−1+Mt,J0=0,∇θℓt=Jt⊤ ∂ℓt∂htJ_t=D_t\,J_{t-1}+M_t,\qquad J_0=0,\qquad\nabla_{\boldsymbol\theta}\ell_t=J_t^\top\,\frac{\partial\ell_t}{\partial\mathbf h_t}

    Differentiate the recurrence: θ\boldsymbol\theta affects ht\mathbf h_t through ht−1\mathbf h_{t-1} and directly. With Dt=∂F/∂ht−1∈Rn×nD_t=\partial F/\partial\mathbf h_{t-1}\in\R^{n\times n} and the immediate derivative Mt=∂F/∂θ∈Rn×pM_t=\partial F/\partial\boldsymbol\theta\in\R^{n\times p}:

  2. Jt⊤ut=∑k=1tMk⊤Pt,k⊤ ut(the BPTT sum for ℓt)J_t^\top\mathbf u_t=\sum_{k=1}^{t}M_k^\top P_{t,k}^\top\,\mathbf u_t\qquad(\text{the BPTT sum for }\ell_t)

    Unrolling gives Jt=∑k≤tPt,kMkJ_t=\sum_{k\le t}P_{t,k}M_k, so Jt⊤utJ_t^\top\mathbf u_t contains exactly the terms of BPTT, summed in a different order. Each loss's gradient is available at the moment the loss is incurred, and the parameters can be updated at every step.

  3. memory O(n3),time O(n4) per step,versus BPTT: O(Tn) memory, O(n2) time per step\text{memory }\order{n^3},\qquad\text{time }\order{n^4}\text{ per step},\qquad\text{versus BPTT: }\order{Tn}\text{ memory},\ \order{n^2}\text{ time per step}

    For a fully connected tanh RNN, Dt=diag⁡(ϕ′(at)) WD_t=\operatorname{diag}(\phi'(\mathbf a_t))\,W, and the recurrent matrix alone contributes p=n2p=n^2 parameters. JtJ_t then has n⋅n2=n3n\cdot n^2=n^3 entries, and the product DtJt−1D_tJ_{t-1} costs n⋅n⋅n2n\cdot n\cdot n^2 multiply-adds per step:

Predict before you look

For a fully connected RNN with n=128n=128 units, how many entries does the influence matrix have for the recurrent weights WW alone? Answer in millions.

Show the answer

2.1 million

n3=1283=2,097,152n^3=128^3=2{,}097{,}152, about 2.1 million numbers (8.4 MB in 32-bit floats), updated at every step with n4≈2.7×108n^4\approx2.7\times10^8 multiply-adds, while a step of the network itself costs about n2≈1.6×104n^2\approx1.6\times10^4. Doubling nn multiplies RTRL's time per step by 16.

Why is forward mode so expensive here? It carries one tangent direction per parameter, pp of them, while reverse mode carries one cotangent per scalar output, and a loss is a single scalar. Reverse mode wins on arithmetic and loses on memory, because it must remember the past. One caveat applies to every online method: when θ\boldsymbol\theta changes at every step, JtJ_t mixes sensitivities computed under old parameters, so the gradient is exact only in the limit of small learning rates.

Cheaper online gradients

UORO (Unbiased Online Recurrent Optimization; Tallec & Ollivier, 2018) replaces JtJ_t by a random rank-one matrix s~tθ~t⊤\tilde{\mathbf s}_t\tilde{\boldsymbol\theta}_t^\top with s~t∈Rn\tilde{\mathbf s}_t\in\R^n and θ~t∈Rp\tilde{\boldsymbol\theta}_t\in\R^p, updated with a fresh vector of random signs ν∈{±1}n\boldsymbol\nu\in\{\pm1\}^n at each step and positive scalars ρ0,ρ1\rho_0,\rho_1 chosen to reduce the variance:

DerivationWhy UORO is unbiased
  1. s~t=ρ0 Dts~t−1+ρ1ν,θ~t⊤=θ~t−1⊤ρ0+ν⊤Mtρ1\tilde{\mathbf s}_t=\rho_0\,D_t\tilde{\mathbf s}_{t-1}+\rho_1\boldsymbol\nu,\qquad\tilde{\boldsymbol\theta}_t^\top=\frac{\tilde{\boldsymbol\theta}_{t-1}^\top}{\rho_0}+\frac{\boldsymbol\nu^\top M_t}{\rho_1}

    The update multiplies the state factor by the dynamics and injects noise; the parameter factor collects the noise's image under MtM_t:

  2. s~tθ~t⊤=Dts~t−1θ~t−1⊤+ρ0ρ1Dts~t−1ν⊤Mt+ρ1ρ0νθ~t−1⊤+νν⊤Mt\tilde{\mathbf s}_t\tilde{\boldsymbol\theta}_t^\top=D_t\tilde{\mathbf s}_{t-1}\tilde{\boldsymbol\theta}_{t-1}^\top+\frac{\rho_0}{\rho_1}D_t\tilde{\mathbf s}_{t-1}\boldsymbol\nu^\top M_t+\frac{\rho_1}{\rho_0}\boldsymbol\nu\tilde{\boldsymbol\theta}_{t-1}^\top+\boldsymbol\nu\boldsymbol\nu^\top M_t

    Expand the product. The ρ\rho's cancel in the first and last terms:

  3. E[s~tθ~t⊤]=Dt E[s~t−1θ~t−1⊤]+Mt=DtJt−1+Mt=Jt\E\big[\tilde{\mathbf s}_t\tilde{\boldsymbol\theta}_t^\top\big]=D_t\,\E\big[\tilde{\mathbf s}_{t-1}\tilde{\boldsymbol\theta}_{t-1}^\top\big]+M_t=D_tJ_{t-1}+M_t=J_t

    The fresh signs are independent of the past, with E[ν]=0\E[\boldsymbol\nu]=\mathbf 0 and E[νν⊤]=I\E[\boldsymbol\nu\boldsymbol\nu^\top]=I. The variance-minimizing ρ1=∥ν⊤Mt∥/∥ν∥\rho_1=\sqrt{\lVert\boldsymbol\nu^\top M_t\rVert/\lVert\boldsymbol\nu\rVert} depends on ν\boldsymbol\nu but is unchanged when ν\boldsymbol\nu flips sign, so the two cross terms, which are odd in ν\boldsymbol\nu, still vanish in expectation, and the last becomes MtM_t. Since the RTRL recursion is affine in JJ, induction from J0=0J_0=0 gives an unbiased estimate at every step:

  4. The cost is one Jacobian–vector product (Dts~D_t\tilde{\mathbf s}) and one vector–Jacobian product (ν⊤Mt\boldsymbol\nu^\top M_t) per step, about the price of running the network a few times, with memory O(n+p)\order{n+p}. The price is variance: the noise injected at every step accumulates, and the estimate can be far from JtJ_t on any single run.

Later methods trade cost against noise. KF-RTRL (Mujika, Meier & Steger, 2018) keeps an unbiased Kronecker-factored estimate, at O(n3)\order{n^3} time and O(n2)\order{n^2} memory per step, with variance smaller than UORO's by a factor of order nn under their assumptions. SnAp (Menick et al., 2021) is biased but deterministic, so it adds no noise: it keeps only the entries of JtJ_t that a parameter can affect within a few steps of the network's sparsity pattern, and with a one-step pattern costs about as much as BPTT. e-prop (Bellec et al., 2020), designed for spiking networks, factors the gradient into a broadcast learning signal times local eligibility traces computed forward in time; its gradient is approximate, yet it approaches BPTT's performance on many tasks with only local, online computation.

MethodGradientMemoryTime per stepComment
BPTTexactO(Tn)\order{Tn}O(n2)\order{n^2}offline: waits for the end
Truncated BPTT, window KKbiasedO(Kn)\order{Kn}O(n2)\order{n^2} (amortized)no signal beyond KK steps
RTRLexactO(n3)\order{n^3}O(n4)\order{n^4}online
UOROunbiasedO(n2)\order{n^2}O(n2)\order{n^2}rank one; high variance
KF-RTRLunbiasedO(n2)\order{n^2}O(n3)\order{n^3}lower variance
SnAp-1biasedO(n2)\order{n^2}about BPTT'ssparse influence matrix
e-propbiasedO(n2)\order{n^2}O(n2)\order{n^2}local, for spiking networks
A fully connected RNN with nn units and p≈n2p\approx n^2 parameters. Online updates make every method approximate in practice. Marschall, Cho & Savin (2020) organize these and other algorithms in one framework.

When exact is cheap. If the recurrence is element-wise, so that each unit's new state depends only on its own previous state (a diagonal DtD_t), then each recurrent parameter influences only its own unit and JtJ_t has O(p)\order{p} nonzero entries: exact RTRL costs about as much as running the network. Irie, Gopalakrishnan & Schmidhuber (2024) trained reinforcement-learning agents with element-wise LSTMs and exact RTRL on memory tasks, and stress the catch: in a stack of such layers, a lower layer's parameters influence every unit above it, and the cost returns. The diagonal recurrences of modern linear RNNs and state space models (Recurrence Returns: xLSTM & Parallel RNNs) have exactly this structure.

Key takeaways

  • Teacher forcing is exact maximum likelihood for the autoregressive factorization; exposure bias is the shift to self-generated prefixes at test time. A learner with error ϵ\epsilon on the expert's states can incur extra cost of order T2ϵT^2\epsilon (Ross & Bagnell, 2010), and training on its own states (DAgger) can restore linear growth.
  • Scheduled sampling is not consistent: cross-entropy is minimized by the true token's conditional given the fed, partly sampled prefix, and with all-sampled inputs that is the marginal. Sequence-level training and professor forcing change the objective instead.
  • Truncated BPTT drops the tail ∑k≤t−Kut⊤Pt,kMk\sum_{k\le t-K}\mathbf u_t^\top P_{t,k}M_k, bounded by order λK/(1−λ)\lambda^K/(1-\lambda) when the dynamics contract; the bias is large exactly when long memories exist.
  • RTRL carries Jt=DtJt−1+MtJ_t=D_tJ_{t-1}+M_t forward: exact online gradients at O(n3)\order{n^3} memory and O(n4)\order{n^4} time per step. UORO (unbiased, rank one), KF-RTRL, SnAp and e-prop trade bias, variance and cost, and element-wise recurrence makes exact RTRL cheap for a single layer.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

What does teacher forcing compute when training an autoregressive RNN?

  1. An approximation to the likelihood gradient that ignores long-range terms
  2. The gradient of a sequence-level metric such as BLEU
  3. A gradient on the model's own samples, to prepare it for generation
  4. The exact gradient of the log-likelihood ∑tlog⁡pθ(yt∣y<t,x)\sum_t\log p_{\boldsymbol\theta}(y_t\mid y_{<t},\mathbf x), with every factor conditioned on the true prefix
Show the answer

D. The exact gradient of the log-likelihood ∑tlog⁡pθ(yt∣y<t,x)\sum_t\log p_{\boldsymbol\theta}(y_t\mid y_{<t},\mathbf x), with every factor conditioned on the true prefix

Maximum likelihood for the factorized model conditions each factor on the true prefix, which is exactly what teacher forcing feeds. The trouble is not the gradient but the shift at generation time, when prefixes come from the model itself.

Question 2

When is the bias of truncated BPTT with window KK guaranteed to be small?

  1. When the Jacobian products contract quickly, γ∥W∥<1\gamma\lVert W\rVert<1 well below 1, so the dropped tail is of order (γ∥W∥)K(\gamma\lVert W\rVert)^K; but then long-range terms were small anyway
  2. Whenever KK is larger than the hidden size nn
  3. When the network has learned long memories, since its gradients are then stable
  4. Never: truncated gradients point in a random direction
Show the answer

A. When the Jacobian products contract quickly, γ∥W∥<1\gamma\lVert W\rVert<1 well below 1, so the dropped tail is of order (γ∥W∥)K(\gamma\lVert W\rVert)^K; but then long-range terms were small anyway

The dropped tail is bounded by ∥ut∥BλK/(1−λ)\lVert\mathbf u_t\rVert B\lambda^K/(1-\lambda) with λ=γ∥W∥\lambda=\gamma\lVert W\rVert. Fast contraction makes it negligible, which is also the regime in which nothing beyond KK steps could be learned. Networks with long memories have Jacobian products near norm 1, and truncation then discards a large part of the gradient.

Question 3

Why does exact RTRL cost O(n4)\order{n^4} per step for a fully connected RNN with nn units?

  1. Because it must store all TT past hidden states
  2. Because it runs BPTT from scratch at every step
  3. Because the influence matrix has n×n2n\times n^2 entries for the recurrent weights, and each step multiplies it by the n×nn\times n Jacobian DtD_t
  4. Because it inverts the recurrent matrix at every step
Show the answer

C. Because the influence matrix has n×n2n\times n^2 entries for the recurrent weights, and each step multiplies it by the n×nn\times n Jacobian DtD_t

RTRL carries Jt=dht/dθJ_t=d\mathbf h_t/d\boldsymbol\theta forward via Jt=DtJt−1+MtJ_t=D_tJ_{t-1}+M_t. With p≈n2p\approx n^2 parameters, JtJ_t is n×n2n\times n^2, and DtJt−1D_tJ_{t-1} costs n4n^4 multiply-adds. Its memory, O(n3)\order{n^3}, does not grow with TT.

Question 4

UORO keeps a rank-one estimate s~tθ~t⊤\tilde{\mathbf s}_t\tilde{\boldsymbol\theta}_t^\top of the influence matrix. What makes it unbiased?

  1. It recomputes the exact influence matrix every few steps
  2. The RTRL recursion is affine in JJ, and fresh random signs with E[νν⊤]=I\E[\boldsymbol\nu\boldsymbol\nu^\top]=I make the cross terms vanish in expectation, so by induction E[s~tθ~t⊤]=Jt\E[\tilde{\mathbf s}_t\tilde{\boldsymbol\theta}_t^\top]=J_t
  3. It uses a learning rate small enough that the bias disappears
  4. The influence matrix of any RNN has rank one
Show the answer

B. The RTRL recursion is affine in JJ, and fresh random signs with E[νν⊤]=I\E[\boldsymbol\nu\boldsymbol\nu^\top]=I make the cross terms vanish in expectation, so by induction E[s~tθ~t⊤]=Jt\E[\tilde{\mathbf s}_t\tilde{\boldsymbol\theta}_t^\top]=J_t

Expanding the update gives four terms; two contain a single ν\boldsymbol\nu and average to zero, and νν⊤Mt\boldsymbol\nu\boldsymbol\nu^\top M_t averages to MtM_t. Unbiasedness says nothing about variance, which is UORO's weakness and the motivation for KF-RTRL.

Further reading

  • R. J. Williams & D. Zipser, "A learning algorithm for continually running fully recurrent neural networks," Neural Computation 1(2), 270–280 (1989).
  • S. Ross, G. J. Gordon & J. A. Bagnell, "A reduction of imitation learning and structured prediction to no-regret online learning," AISTATS (2011).
  • S. Bengio, O. Vinyals, N. Jaitly & N. Shazeer, "Scheduled sampling for sequence prediction with recurrent neural networks," NeurIPS (2015).
  • F. Huszár, "How (not) to train your generative model: Scheduled sampling, likelihood, adversary?," arXiv:1511.05101 (2015).
  • C. Tallec & Y. Ollivier, "Unbiased online recurrent optimization," ICLR (2018).
  • O. Marschall, K. Cho & C. Savin, "A unified framework of online learning algorithms for training recurrent neural networks," Journal of Machine Learning Research 21(135), 1–34 (2020).