techlist.io

Meta Learning

8 posts

OpenAI2019-10-143 min readCurated summary

Solving Rubik’s Cube with a robot hand

# Solving Rubik's Cube with a Robot Hand OpenAI trained a human-like robot hand to solve a Rubik's Cube using neural networks trained entirely in simulation. The approach pairs the reinforcement learning code behind OpenAI Five with a new technique called Automatic Domain Randomization (ADR), which generates progressively harder simulated environments without human tuning. The resulting system transfers to the physical world and handles perturbations it never saw during training, showing that reinforcement learning can solve dexterous physical manipulation problems, not just virtual ones. ## Why Dexterous Manipulation Is Hard - Robotics has long required custom robots for each task, while general-purpose hands have struggled because of their many degrees of freedom. - The team's hardware, a robot hand that has existed for about 15 years, was not new. The novelty was in the software approach. - Solving the cube one-handed is difficult even for children, who take several years to develop the necessary dexterity. ## Training in Simulation with Automatic Domain Randomization - The system uses reinforcement learning in simulation, with Kociemba's algorithm choosing the solution steps. The networks learn the required face rotations and cube flips. - Manually randomizing physics parameters such as friction, elasticity, and dynamics is hard. Too little randomization fails to transfer to the real robot, and too much makes learning difficult. - ADR begins with a single nonrandomized environment. When the network exceeds a performance threshold, the randomization range expands automatically, such as the cube's size, mass, finger friction, or surface materials. The cycle repeats, so training never converges and always stays challenging. - In a block-flipping comparison, ADR initially performed worse than manual randomization on the real robot but eventually roughly doubled the baseline's transfer performance without human tuning. ## Robustness and Emergent Meta-Learning - The ADR-trained system handled perturbations it was never trained on, performing most flips and face rotations under all tested conditions, though not at peak performance. - The authors hypothesize that a memory-augmented network trained on unboundedly varied environments develops meta-learning, learning to adapt its behavior at deployment time. - In simulation, averaged over 10,000 trials, perturbations such as resetting memory, changing dynamics, or breaking a joint caused time-to-success spikes that recovered as the network re-adapted. - Non-negative matrix factorization of the network's memory revealed groups with semantic meaning. For example, the dominant memory group could indicate whether the network was about to spin the cube or rotate the top face clockwise. ## Current Limitations - The system solves a maximally difficult 26-rotation scramble 20% of the time, and a 15-rotation scramble 60% of the time. - Most failures occur during the first few rotations and flips, as the network balances solving with adapting to the physical world. - A dropped cube counts as a failure, though the network can resume solving from any state if the cube is returned to the hand. ## Prototypes Used Along the Way - The team built custom cube prototypes with increasing sensing capabilities, ranging from a locked cube with no internal sensors to a cube with built-in sensors (the Giiker cube), to benchmark progress before tackling a regular cube. - The only modification to the regular cube was cutting a small piece of each center sticker to break rotational symmetry, which allows the vision system to determine orientation. The authors see human-level dexterity as a step toward general-purpose robots. ADR offers a way to train physical-world policies without an accurate model of the real environment, and it removes the need for domain-specific tuning when applying the method to new tasks.

OpenAI2018-05-243 min readCurated summary

Gym Retro

# Gym Retro: A Platform for Generalization Research Across Games OpenAI is releasing the full version of Gym Retro, a reinforcement learning research platform that expands its public game library from roughly 100 titles to over 1,000 across several emulators. The release also includes the integration tool used to add new games. The authors argue that most RL research has focused on solving single tasks, and that a large, varied game collection makes it possible to study generalization between games that share concepts but differ in appearance. The post also shows that simple score-based rewards can lead agents to exploit games rather than complete them, and that current algorithms struggle with sparse rewards and long-horizon planning. ## Scope of the Release - The library grows from about 70 Atari and 30 Sega games to more than 1,000 titles. - Supported consoles include the Sega Genesis, Sega Master System, NES, SNES, and Game Boy, with preliminary support for the Game Gear, Game Boy Color, Game Boy Advance, and NEC TurboGrafx. - Some integrations in the `data/experimental` folder are in beta, and the authors ask for bug reports. - The new code lives on a branch and will not be merged until the ongoing Retro Contest ends, so contestants' code does not break. ## Motivation: From Single Tasks to Generalization - The Retro Contest and its technical report focus on generalizing across levels of one game (Sonic the Hedgehog). - The full dataset extends this to generalization across different games, which is a substantially harder problem. - The authors hope solutions developed by Retro Contest participants can scale to the full dataset. ## Integration Tool - Given a game's ROM, the tool creates save states, locates memory addresses, and defines scenarios that RL agents can solve. - It records and plays back movie files that store only the starting state and button inputs, not every frame. This keeps files small. - Movie files help visualize agent behavior and can store human demonstrations as training data. - An integrator's guide accompanies the tool for developers adding new games. ## Reward Farming - Agents often learn to maximize in-game score instead of completing the intended objective. In Cheese Cat-Astrophe and Blades of Vengeance, agents became trapped in loops that rapidly accumulated points. - Simple reward functions, such as maximizing score, can produce unintended behavior, a phenomenon the authors have discussed before. - Algorithms like PPO perform well on games with dense rewards, where points come frequently and difficulty lies mainly in reaction time. Gradius is an example, since points come from each enemy shot and dodging is handled frame by frame. - Existing algorithms struggle with sparse rewards or tasks that require planning several seconds ahead. Many games in the dataset fall into this category, so tackling the full dataset will likely require new techniques.

OpenAI2018-03-072 min readCurated summary

On first-order meta-learning algorithms

This paper studies meta-learning, where an agent is trained on a distribution of tasks so that it can learn a previously unseen task from the same distribution quickly. The authors analyze a family of algorithms that learns a parameter initialization fine-tunable on new tasks using only first-order derivatives. This family includes first-order MAML and Reptile, a new algorithm the authors introduce. The paper extends earlier results showing these first-order methods perform well on few-shot classification benchmarks, and it offers theoretical analysis of why they work. ### Problem Setting - A meta-learner is trained over a distribution of tasks. - The goal is an initialization that adapts quickly, so the agent performs well on an unseen task after only a few gradient steps. ### First-Order Meta-Learning Algorithms - The family analyzed uses only first-order derivatives in its meta-updates. - It includes first-order MAML, which approximates MAML by dropping second-order derivative terms. - It generalizes these first-order methods within a single analytical framework. ### Reptile - Reptile repeatedly samples a task, trains on it, and moves the initialization toward the weights obtained on that task. - It is a first-order method, so it avoids the cost of computing second-order derivatives. ### Empirical and Theoretical Findings - The results extend Finn et al. and show that first-order methods perform well on established few-shot classification benchmarks. - The authors provide theoretical analysis aimed at explaining why these first-order algorithms succeed.

OpenAI2018-03-063 min readCurated summary

Reptile: A scalable meta-learning algorithm

# Reptile: A Simple, Scalable Meta-Learning Algorithm Reptile is a meta-learning algorithm that finds a neural network initialization from which new tasks can be learned quickly from few examples. It works by repeatedly sampling a task, running standard SGD on it, and moving the initial parameters toward the adapted result. Mathematically it resembles first-order MAML, but it needs only black-box access to an optimizer such as SGD or Adam, and it achieves similar performance with lower computational cost. ## Meta-Learning and the Few-Shot Setting - Meta-learning takes a distribution of tasks, each a learning problem, and produces a learner that generalizes from a small number of examples. - A well-studied case is few-shot classification, where the learner sees only 1–5 examples per class before classifying new inputs. ## How Reptile Differs from MAML - MAML unrolls and differentiates through the gradient descent computation graph, which requires second derivatives. - Reptile runs ordinary SGD on each task and never builds a computation graph or computes second derivatives, so it uses less computation and memory. - The update moves the initialization toward the task-adapted parameters. Treating that difference as a gradient allows plugging it into a more sophisticated optimizer such as Adam. ## Why It Works - With one SGD step per task (k=1), the method reduces to joint training on the mixture of all tasks. Joint training learns little when zero-shot learning is impossible, such as when output labels are randomly permuted. - Reptile requires multiple steps (k>1), where the update depends on higher-order derivatives of the loss. - A Taylor-series analysis shows that the Reptile update maximizes the inner product between gradients from different minibatches of the same task, which corresponds to better generalization. The authors suggest this may also help explain the generalization of SGD outside meta-learning. - Reptile and MAML produce similar updates, containing the same two terms with different weights. ## Experimental Results - On the Omniglot and Mini-ImageNet few-shot classification benchmarks, Reptile and MAML perform similarly. - Reptile converges faster because its update has lower variance. - Summing different combinations of SGD minibatch gradients yields a family of algorithms. Using only the second gradient corresponds to first-order MAML. Including more gradients speeds learning through variance reduction, and using only the first gradient makes no progress, as the analysis predicts. ## Implementations - The official implementation uses TensorFlow and includes code to replicate the Omniglot and Mini-ImageNet experiments. - A smaller JavaScript implementation fine-tunes a TensorFlow-pretrained model and powers the interactive 1-shot classification demo. - A minimal PyTorch example performs few-shot regression on random sine waves from 10 (x, y) pairs. ## Relationship to Prior Work The authors note that first-order MAML and Reptile are more closely related than the names suggest. They take different perspectives but compute similar updates. Reptile's contribution builds on Shortest Descent and on avoiding second derivatives in meta-learning. The post's first paragraph was updated to reflect this.

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-03-202 min readCurated summary

One-shot imitation learning

Researchers propose one-shot imitation learning, a meta-learning approach that lets a robot learn a task from a single demonstration and then perform new instances of that task. Current imitation learning typically needs careful feature engineering or many samples for each task, which is far from the goal of robots that generalize instantly from very little data. The authors argue that training on a broad enough range of tasks could eventually produce a general system that turns any demonstration into a working policy. ## Problem Setting - Existing imitation learning usually solves each task in isolation. - It depends on hand-crafted features or large numbers of demonstrations. - The goal is a robot that learns from very few demonstrations and adapts to new situations of the same task without task-specific engineering. ## Task Structure and Training Data - The authors consider a large set of tasks, where each task has many instances that differ in initial states. - Example tasks include stacking all blocks on a table into one tower, or arranging them into two-block towers. - At training time, the model sees pairs of demonstrations for a subset of tasks. ## Model and Training Objective - A neural network takes as input one demonstration and the current state, which starts as the initial state of the paired demonstration. - It outputs an action, and the goal is for the resulting sequence of states and actions to match the second demonstration as closely as possible. - The model uses soft attention, which the authors credit with generalizing to conditions and tasks not seen during training. ## Test-Time Behavior - At test time, the model receives one demonstration of a single instance of a new task. - It is then expected to perform well on other instances of that same task. ## Outlook - The authors expect that training on a much wider variety of tasks and settings could yield a general system that converts any demonstration into a robust policy for a broad range of tasks.

OpenAI2016-11-082 min readCurated summary

RL²: Fast reinforcement learning via slow reinforcement learning

Deep reinforcement learning can learn sophisticated behaviors, but it needs a huge number of trials, while animals learn new tasks in just a few. The paper proposes RL², which closes this gap by learning a fast reinforcement learning algorithm from data rather than designing one by hand. Experiments show it approaches human-designed algorithms with optimality guarantees on small problems and scales to high-dimensional vision-based tasks. ### The Gap Between Deep RL and Animal Learning - Deep RL learns complex behaviors automatically but requires vast numbers of trials. - Animals adapt to new tasks in a handful of trials by drawing on prior knowledge about the world. - The paper aims to transfer this capacity for rapid learning to artificial agents. ### Learning the Algorithm Instead of Designing It - Rather than hand-designing a "fast" RL algorithm, RL² represents the algorithm itself as a recurrent neural network (RNN). - The RNN's weights encode the learning algorithm and are trained slowly with a general-purpose RL algorithm. - The RNN receives the same inputs a typical RL algorithm would: observations, actions, rewards, and termination flags. - Its hidden state persists across episodes within a given Markov Decision Process (MDP), so its activations hold the state of the fast learner on a new, previously unseen MDP. ### Small-Scale Experiments - RL² is trained on randomly generated multi-armed bandit problems and finite MDPs. - On new MDPs, its performance is close to human-designed algorithms that come with optimality guarantees. ### Large-Scale Experiments - A vision-based navigation task tests whether the approach extends to high-dimensional inputs. - The results indicate that RL² scales beyond toy problems.