On the Variance of Unbiased Online Recurrent Optimization

Tim Cooijmans, James MartensOpenReview 2019

Introduction

Training Recurrent Neural Networks (RNNs) has traditionally presented a difficult trade-off between memory efficiency and computational overhead. The standard approach, Backpropagation Through Time (BPTT), is computationally efficient but requires storing the entire history of hidden states, leading to a memory bottleneck that scales linearly with sequence length. Conversely, Real-Time Recurrent Learning (RTRL) allows for online parameter updates without storing history, but its $O(H^4)$ time and $O(H^3)$ space complexity (where $H$ is the number of hidden units) make it impractical for most architectures.

Unbiased Online Recurrent Optimization (UORO) was recently proposed as a middle ground. By utilizing rank-one stochastic approximations to compress the massive Jacobian matrices of RTRL, UORO achieves $O(H^2)$ complexity. However, this efficiency comes at the cost of high variance in the gradient estimates, which can lead to unstable training. This paper provides a mathematical autopsy of UORO’s variance and introduces several techniques to stabilize online RNN training.

Addressing the Variance of UORO

The core challenge in UORO is that its gradient estimates are "unbiased but noisy." If the noise (variance) is too high, the optimization process fails to converge. The authors move beyond the "greedy" step-by-step variance reduction used in the original UORO implementation and instead take a holistic view of the total gradient accumulated over time.

1. Generalized Recursions and Noise Shaping

The authors replace the simple scalar rescaling factors used in original UORO with matrix-valued transformations ($Q_t$). This allows for more granular control over how noise is distributed across different units in the network. By deriving a formula for the optimal noise-shaping matrix ($Q_0$), they minimize the trace of the total gradient variance, leading to more stable updates than previous "Greedy Iterative Rescaling" (GIR) methods.

2. PREUORO: A Middle-Tier Algorithm

The paper identifies two distinct levels of approximation in UORO: temporal (in time) and spatial (across hidden units). The authors propose PREUORO, a variant that skips the spatial approximation. While this increases the computational complexity to $O(H^3)$, it drastically reduces variance. In tasks requiring long-term memory, PREUORO serves as a powerful intermediary between the noisy $O(H^2)$ UORO and the prohibitive $O(H^4)$ RTRL.

3. The REINFORCE Connection

A significant theoretical contribution of this work is the discovery of a link between gradient-based optimization and reinforcement learning. The authors mathematically demonstrate that as the noise added to an RNN's hidden states approaches zero, the REINFORCE estimator—a common tool in reinforcement learning—converges to the UORO estimator. This provides a unifying framework for understanding stochastic gradient descent in recurrent systems.

Empirical Evaluation

The authors evaluated their proposed methods on two primary benchmarks:

  • Row-wise Sequential MNIST: A variation of the classic digit recognition task where the RNN processes an image one row at a time ($T=28$).
  • The Queue Task: A synthetic benchmark where the model must observe a binary stream and predict the input from $k$ steps ago. This task specifically tests the model's ability to maintain a stable "memory" over time.

Key Results

  • Variance Reduction: The proposed optimal $\alpha$ and $Q_0$ coefficients significantly reduced empirical variance compared to original UORO implementations.
  • Stability: In the Queue task, PREUORO was nearly as stable as exact RTRL, whereas standard UORO struggled to maintain the necessary gradient signal due to noise.
  • Theoretical Validation: The authors' mathematical predictions for variance closely matched their empirical measurements, confirming the robustness of their analytical framework.

Discussion and Limitations

While the paper successfully provides a roadmap for reducing UORO's variance, some practical hurdles remain. The $O(H^3)$ cost of PREUORO, while better than RTRL, still limits its scalability to very large RNNs with thousands of hidden units. Furthermore, the optimal noise-shaping matrix $Q_0$ depends on a matrix $B$ that is difficult to compute online. While the authors proposed an estimator for $B$, it currently possesses high variance itself, making it challenging to implement in a truly "plug-and-play" fashion.

Future research may focus on finding lower-rank approximations of the $B$ matrix to make optimal variance reduction computationally feasible for large-scale models, further bridging the gap between memory-heavy offline training and noisy online optimization.

Summary updated

BibTeX
@misc{cooijmans2019variance,
  author = {Tim Cooijmans and James Martens},
  title = {{On the Variance of Unbiased Online Recurrent Optimization}},
  year = {2019},
  eprint = {1902.02405},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1902.02405},
  howpublished = {OpenReview},
}
Figure