Improving PILCO with a Neural Network Gaussian Process
Introduction and Overview
PILCO is a model-based reinforcement learning algorithm that uses Gaussian Process inference to build a simulated model of a robotics control problem and learn how to solve it. The algorithm can solve non-trivial reinforcement learning problems from scratch with limited data and time. Unfortunately, Gaussian Processes do not scale well to more complex, non-smooth dynamics models.
To fix this issue, a new variant of PILCO called DeepPILCO was created. DeepPILCO replaced the Gaussian Process in PILCO with a Bayesian Neural Network, which allowed the algorithm to model more complex systems. Unfortunately, a neural network requires more data to train than a Gaussian Process, which takes away from the efficiency of the algorithm.
Fortunately, Neal showed in 1996 that a neural network with one hidden layer converges to a Gaussian Process as its width goes to infinity, and a 2017 paper by Lee et al. extended this to deep networks, giving the Neural Network Gaussian Process (NNGP). The related Neural Tangent Kernel describes how infinitely wide networks evolve under gradient descent. My research asked whether replacing PILCO’s Gaussian Process with a Neural Network Gaussian Process would provide any performance gains.
A Quick Overview of the PILCO Algorithm
Consider a dynamical system of the form
where is a vector describing the state of the system at time , is the control signal applied at time , is an unknown function governing the transitional dynamics of the physical system, and is random Gaussian noise.
The goal of PILCO is to find the controller , a deterministic policy which is a function of the current state and parameters that minimizes the expected cost summed over time
To learn the function , PILCO uses Gaussian Process regression. A Gaussian Process is defined by its mean and covariance functions. PILCO utilizes a mean of zero and the Squared Exponential covariance function (kernel) which is defined as
A GP can be thought of as a probability distribution over the possible functions that fit the initial data, which is generated by applying the initial policy in PILCO. PILCO’s GP uses inputs and outputs
to predict the latent function , which in turn is used to predict the difference between states given the previous control signal and the previous state . This probability distribution is assumed to be Gaussian and gives a one-step prediction of the dynamics of the environment. The values are hyperparameters learned via evidence maximization in the original PILCO algorithm.
PILCO creates a long-term cost by evaluating these transitions over time . To do this, the predictive distribution needs to be calculated. Although an exact representation can be given by an integral, it is not analytically tractable, so it is assumed to be Gaussian and then approximated via Gaussian Moment Matching. is then given by
where
The total cost is then given by summing over
for a suitable analytically tractable cost function .
By minimizing the cost function with respect to , the parameters are learned until convergence to a good but not necessarily optimal policy .
Neural Network Gaussian Process modifications to PILCO
In a very general sense, a simple Neural Network can be defined as
where the matrices , are the parameters of the Neural Network and is an element-wise activation function. The goal of the Neural Network is to then learn a relation between the input data and the outputs by minimizing the loss
given by the sum of the squared differences between the training samples and the outputs of the Neural Network , which can be minimized via gradient descent
When the training of is frozen, training a Neural Network under gradient descent is equivalent to kernel regression where acts as the feature map. In this low-dimensional case, this is equivalent to linear regression.
Furthermore, when is sampled from and the dimensions of and tend towards infinity, our Neural Network converges to a Gaussian Process. When this infinite limit has a closed form, it is known as a Neural Network Gaussian Process (NNGP). This NNGP has a kernel that depends on the architecture of the neural network and was meant to act as a drop-in replacement for the GP in PILCO.
Results
I did not end up testing NNGP-PILCO. I implemented PILCO in Python with JAX and GPJax on the cart-pole swing-up problem, and planned to build the NNGP version in Neural Tangents. Neural Tangents’ kernel has no term, so I fixed .
With that setting, the rollouts were nonsensical. From the zero state, the true next state had entries of about and , while my implementation’s predictions were wrong, often reaching about . Changing how long the lengthscale was trained, from 10 to 50,000 iterations, did not fix this.
Conclusion
From this I conjectured that the lengthscale alone cannot encode both and , and that an NNGP would therefore not improve on the GP in PILCO. This is not a conclusive result. My implementation may have contained an error, I trained the hyperparameters differently from the original algorithm, and NNGP-PILCO itself was never run. Testing it directly, or re-deriving PILCO for a kernel with at least two parameters, would be the natural next step.
The slides from my presentation have more detail.