techlist.io

Mujoco

9 posts

OpenAI2018-07-294 min readCurated summary

Learning dexterity

# Learning Dexterity: Training a Robot Hand Entirely in Simulation OpenAI's Dactyl system trains a Shadow Dexterous Hand to reorient physical objects using a reinforcement learning policy learned entirely in simulation, with no fine-tuning on the real robot. The core idea is domain randomization: rather than trying to make the simulator physically accurate, the policy is trained across a wide distribution of randomized physical and visual parameters, so that the real world becomes just one more variation it has already seen. The result is a robot that rediscovers human-like grasps and manipulates blocks and other shapes on hardware, reaching up to 46 to 50 consecutive rotations with vision or motion-tracking feedback. ## The Problem - Dexterous manipulation has lagged behind locomotion in robotics, and the Shadow hand has 24 degrees of freedom compared to 7 for a typical arm. - The robot must handle noisy, delayed sensor readings, occluded fingertips, and unobservable properties such as friction and slippage. - Reinforcement learning works well in simulation but has produced limited results on physical robots. ## Why Not Simulate Realistically or Train on Hardware - Simulators can generate enough data to train complex policies, but manipulation physics (contact, deformable fingertips, tendon stretching, rolling resistance) is hard to model accurately. - Training directly on hardware would take years of real experience for a task like object reorientation. - Domain randomization sidesteps this tradeoff: the simulator prioritizes variety over realism, so policies generalize to the real world. ## Control and Vision Architecture - **Control policy:** An LSTM lets the network infer environment dynamics from its history. It achieved about twice as many rotations as a memoryless policy. Training used Rapid, the scaled PPO implementation from OpenAI Five, on 6,144 CPU cores and 8 GPUs, collecting about 100 years of experience in 50 hours. - **Vision network:** A convolutional network takes three RGB camera views and estimates the object's pose. It was trained only on simulated images rendered in Unity with randomized visual properties. Multiple cameras resolve occlusion and ambiguity. - The two networks are independent and combined at deployment, so the hand can manipulate an object by seeing it. ## Emergent Strategies - Dactyl discovered grasp types from the GRASP taxonomy (tip pinch, palmar pinch, tripod, quadpod, power grasp, and five-finger precision grasp) without being taught them explicitly. - For tip pinches, it favored the thumb and little finger, whereas humans typically use the index or middle finger. The robot's extra little-finger degree of freedom likely explains this choice. ## Results - Randomized policies achieved far more rotations than non-randomized ones. A non-randomized policy managed a median of 0 successes, while the fully randomized policy reached a median of 11.5 with vision and 13 with motion tracking, and a maximum of 46 and 50 respectively. - Vision-based pose estimation performed nearly as well as direct motion-tracking readings. - Without randomization, a policy needed about 3 years of simulated experience to rotate an object. Full randomization required about 100 years, and most of the training time went into robustness to dynamics. ## Surprises and Negative Results - **Tactile sensing was unnecessary.** The policy used only fingertip locations and object pose, ignoring the available touch sensors, because a limited sensor set was easier to model in simulation. - **Randomizations transferred across shapes.** Randomizations designed for a block worked on an octagonal prism without modification. A sphere performed poorly, likely because rolling behavior was not randomized. - **Systems engineering mattered as much as algorithms.** One engineer's faster laptop masked a timing bug that hurt performance for everyone else. - **Faster control did not help.** Reducing the action interval from 80 ms to 40 ms increased training time without improving real-world performance. - **Real data did not help vision.** Simulator-only training matched the accuracy of mixed sim-and-real training, and real tracking data suffered from latency, measurement error, and fragility to configuration changes. ## Conclusion Dactyl demonstrates that scaling domain randomization and recurrent reinforcement learning can solve dexterous manipulation tasks that were previously out of reach for robotics, using a simulation-first pipeline. The authors frame it as one step in a cycle of developing a learning algorithm, scaling it on hard simulated tasks, and transferring the result to the real world.

OpenAI2018-02-253 min readCurated summary

Ingredients for robotics research

# Ingredients for robotics research OpenAI's robotics team released eight simulated robotics environments for Gym, built on the MuJoCo physics simulator, along with a Baselines implementation of Hindsight Experience Replay (HER). The environments are substantially harder than the existing MuJoCo continuous control tasks and use realistic models of real robots, and HER makes it possible to learn them from sparse rewards alone. The post also lists a set of open research directions for extending HER. ## Environments - Eight tasks in total: four using the Fetch research platform and four using the ShadowHand robot. - Tasks are goal-based, such as sliding a puck to a target position or rotating a block to a desired orientation. - The default reward is sparse: -1 until the goal is reached (within a tolerance), then 0. A dense-reward variant is also included, but the authors recommend the sparse version as more realistic for robotics. - The environments were used to train models that work on physical robots. ## Hindsight Experience Replay - Standard RL algorithms learn little from failed attempts when every reward is the same constant (-1). - HER relabels failed episodes by treating the goal the agent actually achieved as if it were the intended goal, which gives a useful learning signal. - Replaying these relabeled experiences with goals chosen after the episode ends is what gives the method its name. - HER works with any off-policy algorithm, such as DDPG (written as "DDPG + HER"). ## Results - On the new tasks, DDPG + HER substantially outperforms vanilla DDPG, which mostly fails to learn. - DDPG + HER with sparse rewards performs best. It learns a successful policy on HandManipulateBlockRotateXYZ from sparse rewards alone. - DDPG + HER with dense rewards learns but reaches lower performance, a trend the authors report as generally true across environments. - Full results are in the accompanying technical report. ## Open Research Directions The authors propose several extensions: - **Automatic hindsight goal creation:** learning the goal-substitution strategy instead of hard-coding it. - **Unbiased HER:** goal substitution distorts the experience distribution, which could be corrected with importance sampling. - **HER + hierarchical RL:** applying substitution to a higher-level policy's actions or subgoals. - **Richer value functions:** conditioning on inputs such as discount factor or success threshold. - **Faster information propagation:** alternatives to target networks, which slow training. - **HER + multi-step returns:** difficult today because the relabeled experience is highly off-policy. - **On-policy HER:** combining HER with stable on-policy algorithms like PPO, possibly via importance sampling. - **RL with very frequent actions:** designing algorithms that keep their performance as the action frequency increases. - **Combining HER with recent RL advances:** such as prioritized experience replay, distributional RL, entropy regularization, or reverse curriculum generation. ## Using the Environments - Goal-based environments use a `gym.spaces.Dict` observation space with three keys: `desired_goal`, `achieved_goal`, and `observation`. - The reward function is exposed, so rewards can be recomputed for substituted goals, which HER-style algorithms require. - Existing Gym-compatible algorithms such as Baselines can use these environments after flattening the dict observation with `gym.wrappers.FlattenDictWrapper`.

OpenAI2017-10-252 min readCurated summary

Learning a hierarchy

# Learning a Hierarchy with Meta-Learning Shared Hierarchies Humans tackle complex problems by chaining together learned sub-skills, but standard reinforcement learning searches over low-level actions one step at a time, which becomes inefficient for long tasks. The post introduces Meta-Learning Shared Hierarchies (MLSH), a hierarchical reinforcement learning algorithm that discovers reusable high-level actions automatically. Applied to navigation tasks, it learns walking and crawling behaviors in different directions that let an agent master new tasks quickly. ## Why Flat Reinforcement Learning Struggles - Current reinforcement learning methods rely on brute-force search over low-level actions, such as individual muscle contractions. - Long tasks requiring thousands of timesteps demand an enormous number of attempts, making these methods very inefficient. - Humans, by contrast, decompose tasks like making pancakes into reusable components and sequence them together. ## Hierarchical Reinforcement Learning - The core idea is to represent complex behavior as a short sequence of high-level actions. - In the authors' example, a solution requiring 2,000 low-level actions becomes 10 high-level actions, and searching a 10-step sequence is far cheaper than searching a 2,000-step one. ## Meta-Learning Shared Hierarchies (MLSH) - A master policy chooses among a set of sub-policies and selects a new action every N timesteps (for example, N=200). - A sub-policy executed for N timesteps forms one high-level action. In navigation tasks, sub-policies correspond to walking or crawling in particular directions. - Unlike most prior work, which hand-engineers hierarchies, MLSH discovers the structure automatically through interaction with the environment. - The method takes a meta-learning view: a good hierarchy is one that enables fast reward acquisition on unseen tasks. - Training samples a distribution of tasks, shares the sub-policies across them, and learns a new master policy for each sampled task. Repeatedly training new master policies pushes the sub-policies toward structures that suit the master's learning dynamics. ## Experiments in AntMaze - A Mujoco Ant robot must navigate from a start position to a goal across a distribution of nine different mazes. - The algorithm finds a diverse set of sub-policies that can be sequenced to solve these mazes, learned purely from environment interaction. - The learned sub-policies can then be reused to master a larger task than those used during training. ## Code Release - The authors released the code for training MLSH agents, along with the MuJoCo environments built to evaluate them.

OpenAI2017-10-102 min readCurated summary

Meta-learning for wrestling

This OpenAI post shows that meta-learning can help simulated robots adapt during a competition. A meta-learning agent defeated a stronger non-meta-learning opponent by adjusting its tactics between rounds, and it could also adjust to physical damage. The authors extended Model-Agnostic Meta-Learning (MAML) so that it optimizes across pairs of environments rather than single ones, which lets policies adapt to unseen environments that are not too different from the training ones. ### Extending MAML with Paired Environments - MAML initializes an agent's policy so that a few gradient ascent steps on the reward from early episodes in a new environment produce better performance there. - The authors changed the objective to optimize against pairs of environments instead of single ones, producing policies that adapt quickly to new environments as long as they do not diverge too wildly from the training set. ### Multi-Round Wrestling Experiments - Three agent types were built: Ant (4 legs), Bug (6 legs), and Spider (8 legs). - Agents played a multi-round game against the same opponent and updated their policy parameters between rounds to counter the opponent's strategy. - Over a hundred agents were trained, some with fixed policies and others with the ability to adapt. Adaptive agents were much stronger competitors than fixed-policy agents. ### Adapting to Physical Malfunction - The same on-the-fly learning let agents cope with changes to their own bodies, such as limbs losing function over time. - The authors suggest this approach could handle both external environmental changes and internal changes to an agent's body or state. The work is part of OpenAI's large-scale multi-agent research, and the authors released the MuJoCo environments and trained policies so others can experiment with these systems.

OpenAI2017-10-102 min readCurated summary

Competitive self-play

# Competitive Self-Play in Simulated 3D Environments OpenAI researchers found that simulated robots trained purely through competition against copies of themselves can learn physical skills such as tackling, ducking, faking, kicking, catching, and diving, without the environment being explicitly designed for them. Because self-play continually matches each agent against opponents of appropriate difficulty, it creates a learning curriculum that human designers would otherwise have to craft by hand. Combined with their earlier Dota 2 results, the work suggests self-play will be a core component of powerful AI systems. ## Experimental Setup - Simulated 3D robots compete in basic games such as sumo wrestling, pushing an opponent out of a ring, reaching the opposite side while blocking the other agent, and soccer-style goal scoring. - Each agent is given only simple goals, and the strategies that emerge are analyzed afterward. - Each agent's neural network policy is trained independently using Proximal Policy Optimization (PPO). ## Reward Shaping and Annealing - Agents first receive dense rewards that encourage exploration, such as standing and moving forward. - These dense rewards are gradually reduced to zero, leaving only the win/loss signal. - In sumo, the team took a walking reward from earlier work, removed the velocity term, and added a negative L2 distance from the ring's center as the exploration reward. - This shaping lets agents learn complex competitive behavior without hand-designed skill objectives. ## Emergent Skills and Transfer Learning - Agents learned tackling, ducking, faking, kicking, catching, and diving through competition alone. - Human-designed environments can only produce behaviors that designers anticipate, while self-play lets agents keep bootstrapping against successively stronger versions of themselves. - A sumo-trained agent kept its balance under "wind" forces it had never encountered, while standard RL-trained walkers fell immediately, suggesting the learned skills generalize. ## Avoiding Overfitting to Specific Opponents - Agents initially co-adapted to counter particular opponents and failed against new ones. - The fix was to train each agent against a diverse pool of opponents, including policies from parallel training runs and earlier checkpoints. - Diversity forces agents to learn general strategies rather than exploits tailored to a single opponent. ## Conclusion The researchers released the MuJoCo environments and trained policies so others can build on this work. The results indicate that self-play, paired with reward annealing and opponent diversity, can produce robust, transferable skills without requiring humans to specify those skills in advance.

OpenAI2017-06-272 min readCurated summary

Faster physics in Python

# Faster Physics in Python: Open-Sourcing mujoco-py 1.50 OpenAI released a major version of mujoco-py, its Python 3 bindings for the MuJoCo physics engine, to support its deep learning robotics research. The release adds efficient parallel simulation, GPU-accelerated headless rendering, direct access to MuJoCo's internals, and support for MuJoCo 1.50 features such as its improved contact solver. Together these changes make batched simulation several times faster and let robotics teams generate large volumes of synthetic training data. ## Batched Simulation with MjSimPool - Trajectory optimization and reinforcement learning methods such as LQR, PI2, and TRPO benefit from running many simulations at once. - mujoco-py uses OpenMP for data parallelism, and Cython and NumPy for direct-access memory management. - Naive use of the new MjSimPool interface is about 400% faster than the previous version. - It is still about 180% faster than an optimized multiprocessing setup achieving the same parallelism. - Most of the gain comes from reduced access times to MuJoCo data structures. ## GPU-Accelerated Texture Randomization - OpenAI uses domain randomization across many projects, and headless GPU rendering provides about a 40x speedup over CPU rendering. - This yields hundreds of synthetic frames per second. - Randomizing a robot's textures during training helps it recognize its own body when transferring from simulation to the real world. ## Virtual Reality Support - The API is sufficient for VR interaction without additional C++ code. - The team ported MuJoCo's C++ VR example to Python using mujoco-py. - The example works with an HTC Vive setup. The support is experimental but has been used internally for some time. ## API and Usage - The `MjSim` class is the simplest entry point. It wraps the model and data, steps the simulation, and renders camera sensor images. - Models are loaded with `load_model_from_path`, and state is read through attributes such as `sim.data.qpos`. - Advanced users can access the MuJoCo C structs and functions directly. The README and full documentation cover these interfaces. ## Conclusion For teams running large-scale robotics simulation or training with synthetic data, mujoco-py 1.50 offers substantial performance gains. MjSimPool is the recommended starting point for batched workloads, and the included examples (`simpool.py`, `disco_fetch.py`) show how to use it.

OpenAI2017-05-143 min readCurated summary

Roboschool

# Roboschool: Open-Source Robot Simulation for OpenAI Gym OpenAI released Roboschool, an open-source robot simulation package integrated with OpenAI Gym. It offers free alternatives to eight MuJoCo environments, re-tuned for more realistic motion, along with new challenging tasks and support for training multiple agents in the same environment. Built on the permissively licensed Bullet Physics Engine, it removes the paid-license barrier that MuJoCo imposed on researchers. ## Free Alternative to MuJoCo - The MuJoCo dependency required a paid license, a common complaint among Gym users, though MuJoCo later added free student licenses. - Roboschool is built on the Bullet Physics Engine, an open-source library also used by simulators such as Gazebo and V-REP. - Twelve environments ship with the package, including ported MuJoCo tasks modified for more realistic behavior and new challenges. - Trained policies for these environments are available in the `agent_zoo` folder, and a `demo_race` script lets three robots race each other. ## Interactive and Robust Locomotion - Earlier Gym walking tasks only required moving forward, so learned policies often settled into a single cyclic gait, left most of the state space unexplored, and fell over after small pushes. - **HumanoidFlagrun** requires the 3D humanoid to run toward a flag whose position changes randomly, teaching it to slow down and turn. - **HumanoidFlagrunHarder** adds more difficulty: episodes start with the robot upright or lying down, the robot may fall and must get back up, and white cubes are constantly thrown at it to knock it off course. - The resulting policies are less fast and natural-looking than the regular humanoid's walk, but they recover from many disturbances and steer well. Because the policy is a multilayer perceptron with no internal state, the authors suspect the agent sometimes uses its arms to store information. ## Multiplayer Training - Roboschool supports running and training multiple agents in one environment, starting with a multiplayer Pong environment. - Setups include self-play (one agent playing both sides), two agents trained with the same algorithm, or two agents trained with different algorithms. - Training both players simultaneously with policy gradient methods caused oscillation: each agent learned a counter-strategy, then overfit to it, and neither improved after hours of training. - The authors note that adversarial learning is difficult, much like GANs, but it can produce sophisticated strategies in simple environments and a natural curriculum, making it a worthwhile research problem. ## Related Work - Other community projects have built Gym environments on open-source physics simulators. One fork replaced MuJoCo with the DART simulator and showed that policies transfer between MuJoCo and DART.

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.

OpenAI2016-04-263 min readCurated summary

OpenAI Gym Beta

# OpenAI Gym Beta: A Shared Toolkit for Reinforcement Learning Research OpenAI has released the public beta of OpenAI Gym, an open toolkit for developing and comparing reinforcement learning (RL) algorithms. It pairs a growing suite of environments, ranging from simple control tasks to Atari games and simulated robots, with a site for comparing and reproducing results. The authors built it to speed up their own research and hope it becomes equally useful to the wider community. ## Why RL Needs Better Infrastructure - RL covers any problem involving a sequence of decisions, such as robot locomotion, pricing and inventory management, video games, and board games. It has also been applied to supervised problems with sequential or structured outputs. - Recent deep RL systems, including DeepMind's Atari work, BRETT, and AlphaGo, make few assumptions about their environments, so they transfer across settings. Earlier RL methods required heavy problem-specific engineering. - Two obstacles slow progress: - **Weak benchmarks:** Supervised learning advanced through large labeled datasets like ImageNet. RL lacks an equivalent, and existing open-source environment collections are narrow and often hard to set up. - **Inconsistent environments:** Small differences in reward functions or action sets can change a task's difficulty dramatically, which makes published results hard to reproduce or compare. ## The Environment Suite - **Classic control and toy text:** Small-scale tasks from the RL literature, intended as a starting point. - **Algorithmic:** Tasks such as adding multi-digit numbers or reversing sequences, learned purely from examples. Difficulty scales with sequence length. - **Atari:** Classic games through an easy-to-install integration of the Arcade Learning Environment. - **Board games:** Go on 9x9 and 19x19 boards against a fixed Pachi opponent. Multi-player support is planned. - **2D and 3D robots:** Simulated control tasks built on the MuJoCo physics engine, including environments from a UC Berkeley benchmark. MuJoCo is proprietary but offers free trial licenses. Each environment carries a version number, such as Hopper-v0. Any change to an environment produces a new version, so results on a given version stay comparable over time. ## Evaluation Without Leaderboards - Users can upload results, but OpenAI chose not to build traditional leaderboards, since raw scores can be gamed through overfitting or hand-crafted solutions. - Instead, a curated list highlights contributions that show something interesting about algorithmic capability. The long-term goal is for this curation to be community-led. - Partners supporting the launch include NVIDIA (technical Q&A), Nervana (a DQN agent implementation), and AWS (US$250 credit vouchers for promising, resource-constrained researchers). ## Getting Involved - Work through the tutorial, or reproduce an existing result. - During the beta, feedback is requested on making the tool better for research. Contributors can push the state of the art on each environment, reproduce published results, or build new environments. Community chat is open.