year: 2017
paper: Evolution Strategies as a Scalable Alternative to Reinforcement Learning
website: https://openai.com/index/evolution-strategies/
code: https://github.com/openai/evolution-strategies-starter | Karpathy gist | es-torch
connections: evolutionary optimization, RL, OpenAI, Illya Sutskever, natural evolution strategies, optimization


Evolution Strategies

Evolution Strategies (ES) is a class of black box optimization algorithms [Rechenberg and Eigen, 1973, Schwefel, 1977] that are heuristic search procedures inspired by natural evolution: At every iteration (“generation”), a population of parameter vectors (“genotypes”) is perturbed (“mutated”) and their objective function value (“fitness”) is evaluated. The highest scoring parameter vectors are then recombined to form the population for the next generation, and this procedure is iterated until the objective is fully optimized. Algorithms in this class differ in how they represent the population and how they perform mutation and recombination.

NES

This paper uses NES, where an objective function acting on parameters is optimized. What makes it a natural evolution strategy is that we arre not directly optimizing , but optimizing a distribution over paramaters (“populations”) –itself parametrizd by – and proceed to maximize the average objective value over the population by searching for with stochastic gradient ascent, using the score function estimator for similar to REINFORCE.
So gradient steps are taken on like this:

We estimate the gradient by sampling the distribution because we can’t integrate over all possible values of .
Their population distribution is a factored gaussian, the resulting gradient estimator is known as “simultaneous perturbation stochastic approximation”, “parameter-exploring policy gradients”, and “zero-order gradient estimation”.
The initial population distribution is an isotropic multivariate gaussian, with mean and fixed covariance .
Initially, we optimize which controls a population distribution that generates parameters . However, by fixing as a Gaussian with mean and variance , we can simplify this to directly optimizing by simply adding Gaussian noise during sampling. This transforms the problem from optimizing population distribution parameters () to directly optimizing the mean () of a fixed-form Gaussian, while maintaining exploration through noise injection. The resulting simplified gradient estimator:

This noise / gaussian blurring also allows us to train on non-differential / unsmooth environments.
center

In parallel.

In the parallel version, the random seeds are fixed, such that the computation of parameter updates can happen on each worker independently, just the rewards need to be communicated. The duplicate operations (lines 9-12) are negligible.
center
One can imagine letting each worker only perturb a subset of parameters. mixture of gaussians
With only one parameter change per worker → pure finite differences.

They say that not computing all the param updates on each worker would reduce computation in (9-12). But wouldn’t they have to communicate parameters again then?

When (not) to use ES?

TLDR: Depends strongly on the problem and monte-carlo estimator for gradients, but ES is better for long-horizon, long-lasting action effect, no good value-function available type problems (i.e. most things which are not games or toy problems).

We generally want a gradient estimator with lower variance:
High Variance → Need smaller learning rate → Slower learning
High Variance → Need more samples → More expensive training
High Variance → Less reliable updates → Potentially worse final performance

Assume correlation between reward and individual actions is low (as in any hard RL problem).
The variance of the gradient estimator (in this case simple monte-carlo, aka REINFORCE) for the two strategies is:

If both methods perform similar amounts of exploration, the variance from the reward term will be similar.
The gradient for the policy-gradient method is , a sum of uncorrelated terms, so its variance grows linearly with (the timesteps where an action is chosen in each).
The corresponding term for ES is has a variance is independent of because the noise in is independent of the timesteps → Better for long-horizon problems.

Policy Gradients variance ; ES variance

Variance in ES can be controlled by adjusting :
Smaller → lower variance but might miss good directions
Larger → higher variance but better exploration.
Or increasing the number of samples:
More samples → lower variance (by factor of ) but more computationally expensive

reward discounting reduces variance drastically, but is only applicable if actions have a short-lasting effect on the environment, else the gradients are biased.

Function approximation (for reducing the value of ) also runs the risk of biasing the gradients.

Variance methods used in this work.

“antithetic sampling” / “mirrored sampling”:
They always evaluate paris of perturbations for the gaussian noise-vector .
fitness shaping / applying a rank transformation to rewards:
To reduce the effect of outliers in the reward signal, applying a rank transformation means looking at their relative performance either like this [100,2,1]->[3,2,1] or normalized ranks like [1,.5,0].
This helps prevent premature convergence to local optima because one really good result pulls too strongly.

we did not see benefit from adapting during training, and we therefore treat it as a fixed hyperparameter instead. We perform the optimization directly in parameter space; exploring indirect encodings (HyperNEAT, A Wavelet-based Encoding for Neuroevolution) is left for future work.

Are indirect encodings that promote regular structure like HyperNEAT good priors?

Weight decay during training.

This prevents the parameters from growing very large compared to the perturbation — i.e. the noise is not drowned out by the parameters (no exploration).

ES can be seen as computing a finite difference derivative estimate in a randomly chosen direction, especially as becomes small.

This means, that for general non-smooth optimization problems, the required number of optimization steps scales linearly with the number of parameters .

However, it is important to note that this does not mean that larger neural networks will perform worse than smaller networks when optimized using ES: what matters is the difficulty, or intrinsic dimension, of the optimization problem.

So something like approximating with does not become more difficult if we double the features and params by concatting with itself . It will do exactly the same, as long as we divide the standard deviation of the noise by two, as well as the learning rate.
Why?
Because in this example, we’ve just represented the same problem in a higher dimensional space.
The adjustments need to be made because the noise sample vector is now twice as long, meaning the magnitude of the perturbation would be larger just because there are more dimensions. The variance of from adding gaussian variables grows with the of the number of dimensions.
The intrinsic difficulty of the problem stayed the same (think of it as talking a straight linein 2D vs 3D).
Of course the computational effort is still higher, but not the number of steps.
Just adding parameters does not make the optimization problem harder aka require you to do more steps, just if the additional parameters actually add to the problem.
In fact, bigger models are less prone to getting stuck in local optima.

Advantages of not calculating gradients.

By not requiring backpropagation, black box optimizers reduce the amount of computation per episode by about two thirds, and memory by potentially much more. In addition, not explicitly calculating an analytical gradient protects against problems with exploding gradients that are common when working with recurrent neural networks. By smoothing the cost function in parameter space, we reduce the pathological curvature that causes these problems: bounded cost functions that are smooth enough can’t have exploding gradients. At the extreme, ES allows us to incorporate non-differentiable elements into our architecture, such as modules that use hard attention.

Black box optimization methods are uniquely suited to low precision hardware for deep learning. Low precision arithmetic, such as in binary neural networks, can be performed much cheaper than at high precision. When optimizing such low precision architectures, biased low precision gradient estimates can be a problem when using gradient-based method.

By perturbing in parameter space instead of action space, black box optimizers are naturally invariant to the frequency at which our agent acts in the environment. For MDP-based reinforcement learning algorithms, on the other hand, it is well known that frameskip is a crucial parameter to get right for the optimization to succeed [Braylan et al., 2005]. While this is usually a solvable problem for games that only require short-term planning and action, it is a problem for learning longer term strategic behavior. For these problems, RL needs hierarchy to succeed [Parr and Russell, 1998], which is not as necessary when using black box optimization.

Paper comparing ES to PPO: Qualitative Differences Between Evolutionary Strategies and Reinforcement Learning Methods for Control of Autonomous Agents also introduces super-symmetric sampling, making the algorithm more efficient.

combine ES + UPGD + SSS?

Some optimizations for the current replica impl: