techlist.io

Policy Gradients

2 posts

OpenAI2019-03-033 min readCurated summary

Neural MMO: A massively multiagent game environment

# Neural MMO: A Massively Multiagent Game Environment for Reinforcement Learning OpenAI released Neural MMO, a game environment for reinforcement learning that hosts a large, variable number of agents in a persistent, open-ended world. The authors argue that existing environments are either complex but narrow, or open-ended but simple, and that massively multiagent settings can fill this gap. Their experiments show that larger populations and more species lead to better exploration, niche formation, and overall agent competence. ## Design Goals The authors built Neural MMO around four criteria: - **Persistence:** Agents learn concurrently with other learning agents and no environment resets occur, so strategies must account for long time horizons and shifting behaviors of other agents. - **Scale:** The environment supports a large, variable number of entities. Experiments ran up to 100M lifetimes of 128 concurrent agents across 100 concurrent servers. - **Efficiency:** Effective policies can be trained on a single desktop CPU, keeping the barrier to entry low. - **Expansion:** Modeled on existing MMOs, the environment is designed to grow with new content. Current features include procedurally generated tile-based terrain, food and water foraging, and strategic combat. ## Environment Mechanics - Agents join any available server, each generating a tile-based map of configurable size. - Forest and grass tiles are traversable, while water and stone are not. - Agents spawn along the map edges and must manage health by obtaining food and water while avoiding combat damage. - Forest tiles hold limited food that regenerates slowly, so agents compete for it. Water tiles are infinite. - Combat uses three styles: Melee, Range, and Mage. - **Observations:** Agents see a square crop of tiles centered on their position, including terrain types and the health, food, water, and position of nearby agents. - **Actions:** Each tick, agents output one movement and one attack. ## Training Approach - The baseline is a small, fully connected network trained with vanilla policy gradients, a value function baseline, and reward discounting. - Agents receive a reward of 1 for each tick they survive, so they optimize for lifetime rather than explicit objectives. - Variable-length observations, such as lists of nearby players, are converted to fixed-length vectors by taking the maximum across entities, a trick also used by OpenAI Five. - The released code uses PyTorch and Ray for distributed training. ## Emergent Behaviors - **Server merge tournaments:** Policies trained in larger settings consistently outperformed those trained in smaller ones when players from different servers were merged to compare them directly. - **Exploration from competition:** Map coverage increased with the number of concurrent agents, since the presence of others naturally pushes agents to spread out. - **Niche formation:** With more populations, agents separated across the map to avoid competing with their own kind, seeking regions with enough resources to sustain their population. DeepMind independently observed similar effects. - **Learned dependencies:** A value-function visualization showed agents' policies depend on the positions of other agents. Agents learned "bull's eye" avoidance maps to forage effectively within minutes, and they learned appropriate engagement ranges and approach angles in combat. ## Conclusion Neural MMO combines moderate environment complexity with large population scale, and the authors designed it for open-source expansion so the research community can build on it. They present it as a step toward solving the limitations of prior game-based environments, while acknowledging that many open problems remain.

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.