techlist.io

Evolution Strategies

3 posts

OpenAI2018-04-173 min readCurated summary

Evolved Policy Gradients

# Evolved Policy Gradients: Learning the Loss Function Instead of the Policy OpenAI's Evolved Policy Gradients (EPG) is an experimental metalearning method that evolves the loss function used by learning agents rather than a policy or a reward function. Once evolved, the learned loss lets agents learn quickly on novel tasks and generalize beyond their training distribution, such as walking to a target on the opposite side of an arena from anything seen in training. EPG can also train agents faster than PPO, though the learned losses are currently narrow and do not transfer to very different kinds of tasks. ## Encoding Prior Knowledge as a Loss - Most RL agents start from a blank slate and depend entirely on external rewards, which is why they learn simple skills far more slowly than humans. - EPG instead encodes prior knowledge as a learned loss function, parameterized as a temporal-convolutional neural network, that tells the agent what counts as making progress. - The method is related to earlier work on evolving reward functions, but it goes further by evolving a complete loss, so the loss must effectively encode an RL algorithm internally. ## Two-Loop Optimization - **Inner loop:** An agent learns a task from scratch using stochastic gradient descent, optimizing its policy against the loss proposed by the outer loop. Tasks come from a family, such as "move gripper to target location [x, y]." - **Outer loop:** Evolution Strategies (ES) evaluate the returns achieved after inner-loop learning and adjust the loss parameters to produce higher returns. - Because ES optimizes final trained-policy performance rather than short-term returns, and the loss can adapt to the environment and the agent's history, the approach offers advantages over standard RL losses. ## Why Learn a Loss Instead of a Policy - Recurrent meta-learned policies tend to overfit the tasks they were trained on, and learned policy initializations offer limited help with exploration. - Loss functions are expected to generalize better across substantially different tasks, as hand-designed losses like PPO's already do across Atari and robotics. ## Generalization Experiment - Researchers evolved an EPG loss so that simulated "ants" learned to walk to random targets on the right half of an arena. - With the loss frozen, the ants were given targets on the left half. They learned to walk left, a case outside the training distribution. - RL², a baseline metalearning method that directly learns an adaptive policy, succeeded on the right-side targets but kept walking right when given left-side targets, which suggests it overfit to its training tasks. ## Limitations - An EPG loss is currently effective only for one small family of tasks at a time. It is unlikely to work on a very different task, such as Space Invaders. - Standard RL losses are general enough to learn a wide range of skills, so EPG trades generality for performance. - Metalearning methods that both outperform standard RL and retain its generality remain a long-term goal.

OpenAI2017-09-283 min readCurated summary

Nonlinear computation in deep linear networks

# Nonlinear Computation in Deep Linear Networks The post argues that deep linear networks, when implemented with floating-point arithmetic, are not truly linear. Near zero, float32 rounding and underflow introduce genuine nonlinearities, and evolution strategies can exploit them to solve problems that a standard linear network trained by backpropagation handles poorly. On MNIST, this approach lifts a linear network's test accuracy from 92% to 96.7%. ## Why Floating-Point Arithmetic Is Nonlinear - Neural networks normally alternate linear layers with nonlinear activations like tanh or ReLU. In exact math, stacked linear layers collapse into one linear layer. - Computers approximate real numbers with finite bits. In IEEE float32, a number has 1 sign bit, 8 exponent bits, and 23 fraction bits. - The smallest normal positive number is `min` = 1.0...0 × 2^-126. The gap between 0 and `min` is about 2^20 times larger than the gap between `min` and the next representable number, so values below `min` underflow to zero. - Because of this underflow, arithmetic near zero stops obeying the usual algebraic laws. The post gives two examples: - With a = 0.4×min, b = 0.5×min, c = 1/min, the expression (a+b)×c evaluates to 0, while (a×c)+(b×c) evaluates to 0.9. - With a = 2.5×min, b = −1.6×min, c = 1×min, (a+b)+c gives min, but (b+c)+a gives 2.5×min. - TensorFlow builds its primitives with denormals disabled (`ftz=true`), so any non-matrix-multiply operation near magnitude 1e-38 carries an implicit nonlinearity. ## Exploiting the Nonlinearity with Evolution Strategies - Standard backpropagation relies on symbolic differentiation, which cannot see these tiny-scale nonlinearities, so it struggles to train networks that depend on them. - Evolution strategies (ES) estimate gradients by sampling perturbations of the parameters instead of differentiating the computation, so they can exploit the behavior. - The authors scale activations so they fall into float32's nonlinear near-zero range. The architecture is a 784→512→512→10 network with no nonlinear activations, using scaling factors of 2^125 to keep intermediate values in that range. ## Results - A deep linear network trained with backpropagation reached about 94% training and 92% test accuracy on MNIST. - The same linear architecture trained with ES reached over 99% training and 96.7% test accuracy. - The authors attribute the gain to the float32 nonlinearities, which let each layer form nonlinear combinations of lower-level features. ## Future Directions - The authors suggest extending the approach to recurrent neural networks. - They also propose using these nonlinearities to improve harder tasks such as language modeling and machine translation.

OpenAI2017-03-234 min readCurated summary

Evolution strategies as a scalable alternative to reinforcement learning

Evolution strategies (ES), a decades-old black-box optimization method, can match standard reinforcement learning (RL) methods on modern benchmarks like Atari and MuJoCo while avoiding many of RL's practical burdens. ES needs no backpropagation, is simpler to implement, scales far more easily across distributed machines, handles sparse rewards well, and has fewer hyperparameters. The authors show that ES can train a 3D humanoid walker in 10 minutes on 1,440 CPU cores, where A3C needed about 10 hours on 32 cores, and reach comparable Atari performance in one hour instead of one day. ## How Reinforcement Learning Works - A policy, usually a neural network with on the order of a million parameters, maps the current state to probabilities over actions. - Training collects episodes of interaction, then uses backpropagation to nudge the network toward actions that preceded good outcomes and away from those that preceded bad ones. - Exploration comes from sampling actions from a stochastic policy, which injects noise into the agent's actions. ## Evolution Strategies as Black-Box Optimization - Despite the name, ES has little to do with biological evolution. It is best understood as a family of black-box stochastic optimization methods. - The environment, the agent, and the time structure of episodes are all abstracted away. The method sees only a million-dimensional parameter vector go in and a single total reward come out. - Each step perturbs the current parameters with Gaussian noise to create a population (for example, 100 candidates), evaluates each candidate's total reward, and moves the parameters toward a reward-weighted average of the perturbations. - Mathematically, this is a finite-difference estimate of the gradient of expected reward along random directions. It can also be viewed as REINFORCE with a Gaussian policy over whole parameter vectors. - A short NumPy example minimizes a quadratic with this procedure, illustrating how little code is required. - Because noise is injected into parameters rather than actions, ES can use deterministic policies and can optimize non-differentiable networks. ## Advantages of ES over RL - **No backpropagation:** Only forward passes are needed, making the code shorter and about 2 to 3 times faster in practice. Episodes need not be stored, and exploding gradients in RNNs are not a concern. - **Highly parallelizable:** Workers share random seeds and only exchange scalar rewards, rather than synchronizing parameter vectors with millions of entries. The authors observed linear speedups up to thousands of CPU cores. - **Robustness:** RL can fail badly under different Atari frame-skip settings, whereas ES performs about equally well across them. - **Structured exploration:** Policy-gradient methods often start with random jitter in place. ES, using deterministic policies, produces consistent behaviors. - **Long time horizons:** Analysis of both gradient estimators suggests ES is especially attractive when episodes are long, actions have lasting effects, or good value estimates are unavailable. ## Challenges and Limitations - ES requires that parameter noise produce different outcomes so that a gradient signal exists. Virtual batch norm helped, but better parameterizations are needed. - In Montezuma's Revenge, a random network almost never retrieves the key on the first level, whereas random actions occasionally do. - ES is about 1,000 times slower than backpropagation for supervised tasks such as MNIST, so its advantage is specific to RL settings, where gradients must be estimated by sampling. ## Benchmark Results - On MuJoCo, ES reaches performance comparable to TRPO but is roughly a factor of 10 less data-efficient in the worst case. - On wall-clock time, ES solved the 3D humanoid task in 10 minutes on 1,440 CPUs across 80 machines. A3C on 32 cores took about 10 hours, and the authors note that naive A3C scaling in cloud settings is limited by communication bandwidth. - On Atari, ES on 720 cores in one hour matches A3C on 32 cores in one day across games such as Pong, Seaquest, and Beamrider. In Seaquest, the submarine learns to surface when oxygen runs low. ## Context and Conclusion - The work follows a broader pattern of revisiting decades-old ideas, similar to how AlexNet and Deep Q-Learning revived CNNs and Q-learning. - The authors' contributions are scaling ES to distributed settings, adapting it to deep networks (such as with virtual batch norm), and evaluating it on modern RL benchmarks. Their work builds on Natural Evolution Strategies (Wierstra et al., 2014). - The authors conclude that neuroevolution can compete with RL on modern benchmarks while being simpler and easier to scale, and suggest future directions such as indirect encoding and evolving network structure.