Calculating gradients in complex, stochastic systems like Reinforcement Learning (RL) is a notoriously difficult challenge. By revisiting the "total derivative rule"—a fundamental calculus concept often overshadowed by the chain rule—this NeurIPS 2018 paper by Paavo Parmas builds a visual framework that unifies existing policy gradient theorems and introduces powerful new ways to train agents.
The Challenge of Stochastic Gradients
In machine learning, we frequently need to calculate the gradient of an expectation, such as determining how changing a policy's parameters will affect the expected reward. Traditionally, there are two primary ways to approach this:
- Pathwise Derivatives (Reparameterization): Differentiating directly through the sampled trajectories. While accurate, this method can lead to "exploding gradients" in long-running simulations—a phenomenon known as the curse of chaos.
- Jump Gradients (Likelihood Ratio): Estimating the gradient based on how the probability of an outcome changes. This method is more robust to chaotic dynamics but often suffers from unacceptably high variance.
Prior to this work, frameworks for combining these methods were rigid and heavily algebraic. Researchers lacked an intuitive, visual way to decompose a complex system into parts that could be estimated using different techniques. Furthermore, the success of popular model-based algorithms like PILCO remained somewhat mysterious and difficult to replicate with simpler particle-based methods.
Probabilistic Computation Graphs and New Estimators
The core contribution of this paper is the Total Stochastic Gradient Theorem. Unlike standard backpropagation, which follows a single chain, this theorem allows researchers to decompose a gradient into a sum of partial derivatives along different computational paths.
To make this intuitive, the author introduces Probabilistic Computation Graphs (PCGs). In a PCG, nodes represent random variables and edges represent the deterministic functions governing their distribution parameters (such as mean and variance).
Using this framework, the paper introduces several novel approaches:
- Density Estimation LR (DEL): A method that fits a distribution (like a Gaussian) to a set of sampled "particles" and then uses the Likelihood Ratio trick on that estimated distribution. This allows for "jump" gradients even in systems where no noise is explicitly injected.
- Gaussian Shaping Gradient (GS): This technique fits Gaussians at intermediate nodes in the graph to "jump" the gradient over complex, chaotic sections. It effectively smooths the optimization landscape by bypassing problematic paths.
- GTP (Gaussian shaping with Total Propagation): A hybrid algorithm that combines these intermediate "jumps" with pathwise derivatives to capture the best of both worlds—mitigating chaos while controlling variance.
Key Insights and Results
The PCG framework provides a profound theoretical unification: it demonstrates that the famous "Policy Gradient Theorem" and "Deterministic Policy Gradient Theorem" are not distinct entities. Rather, they are simply different ways of traversing the exact same Probabilistic Computation Graph. This visual logic allows for the derivation of complex theorems in just a few lines, replacing pages of algebraic proofs.
Furthermore, the paper demystifies the success of PILCO. Previously, PILCO's effectiveness was attributed to "reward smoothing." Parmas argues that the real advantage is that PILCO's Gaussian approximations act as a natural gradient estimator that prevents the "curse of chaos" by decoupling the gradient from the specific, noisy trajectories of individual particles.
When evaluated on classic RL control benchmarks, the proposed methods shine:
- Performance Matching: On the notoriously difficult cart-pole swing-up task (using the PILCO "Tip Cost" function), the proposed GTP algorithm achieved success rates of approximately 70-80%, matching the original PILCO algorithm. In contrast, standard pathwise gradients failed entirely, hovering around a 15% success rate.
- Variance vs. Bias: While the new DEL estimator introduces bias (due to its Gaussian assumption), experiments confirm it provides a stable, usable optimization signal in tasks where unbiased methods fail due to variance or exploding gradients.
Limitations and Future Directions
The primary limitation of the GS and DEL methods is their reliance on fitting Gaussians to particles. If the true distribution is highly multi-modal (e.g., an agent deciding whether to go left or right around an obstacle), a single Gaussian approximation will fail to capture the dynamics accurately. Additionally, scaling density estimation to very high-dimensional spaces, such as raw video input, remains a significant hurdle.
Ultimately, this framework paves the way for a new generation of automatic differentiation software. Future tools might not just optimize for computational speed, but could automatically select the most accurate type of gradient estimator for different segments of a complex stochastic program.
Summary updated