techlist.io

Energy Based Models

3 posts

OpenAI2019-03-203 min readCurated summary

Implicit generation and generalization methods for energy-based models

# Energy-based Models: Sampling Through Iterative Refinement OpenAI's research on energy-based models (EBMs) argues that they can match GAN-level sample quality at low temperatures while keeping the mode coverage of likelihood-based models. The approach generates samples implicitly through iterative refinement, which trades extra compute for better outputs. The authors also report better out-of-distribution generalization and adversarial robustness than comparable likelihood models, and they present early evidence that EBMs compose well. ## How Energy-based Models Work - EBMs assign an unnormalized probability scalar (an "energy") to each input, so any model that outputs a real number can serve as an energy function. - Sampling is the hard part. Samples are produced with Langevin dynamics, which performs noisy gradient descent on the energy function to reach low-energy configurations. - Unlike GANs, VAEs, and flow-based models, EBMs need no separate generator network. Samples are generated implicitly. ## Key Advantages - **Adaptive computation time:** Running refinement longer yields sharper, more diverse samples, while shorter runs give coarser, less diverse ones. In the limit of infinite steps, the procedure theoretically produces true samples from the model. - **No generator bottleneck:** VAEs and flow-based models must map a continuous space onto possibly disconnected data modes, which demands large capacity. EBMs can assign low energy to disjoint regions directly. - **Built-in compositionality:** Because each model defines an unnormalized distribution, models can be combined through a product of experts or other hierarchical structures. ## Generation Results - With longer test-time refinement, EBMs produce high-quality images. Iterative optimization enables image auto-completion and morphing between classes, such as truck to frog. - On robot dynamics, EBMs generate stable trajectories over many timesteps and produce diverse possible futures, whereas feedforward models collapse to a mean prediction. ## Generalization Results - On several out-of-distribution datasets, EBMs outperform other likelihood models, including flow-based and autoregressive models. - Conditional EBMs generalize well to adversarial perturbations. Despite never being trained for classification, they outperform models explicitly trained against adversarial examples. ## Lessons from Training - Vanilla HMC is hard to apply because optimal step sizes and leapfrog step counts shift considerably during training. Adaptive HMC is suggested as future work. - Ensembles of energy functions helped slightly but did not justify the added complexity. - A gradient penalty term hurt model capacity and sampling quality. - The authors caution that these observations are tentative. More details appear in Section A.8 of the paper. ## Compositionality Experiments - One model was trained on shapes of varying sizes at a fixed position, and another on fixed-size shapes at varying positions. - Combining them via a product of experts produced shapes of different sizes at different locations, even though the model never saw examples of both variations together.

OpenAI2018-11-063 min readCurated summary

Learning concepts with energy functions

# Learning Concepts with Energy Functions OpenAI researchers developed an energy-based model that learns to identify and generate abstract concepts, such as "near," "between," or "furthest," from just five demonstrations. The concepts are expressed as sets of 2D points, and the model can transfer them across domains: concepts learned in a 2D particle environment are used to solve tasks on a 3D physics-based robot without retraining. The authors argue that forming reusable concepts is a basic building block of generalization, abstract reasoning, and planning. ## Why Concepts Matter - Human intelligence relies on consolidating experience into concepts, such as visual ("red," "square"), spatial ("inside," "on top of"), temporal ("slow," "after"), and social ("helpful") ones. - Concepts give agents basic building blocks for understanding and reasoning, enabling them to generalize from limited experience. ## How Energy Functions Represent Concepts - Energy models are inspired by physics: observed states correspond to low-energy configurations. - Each concept is defined by an energy function E(x, a, w) with three inputs: - **x**: the state of the world, composed of entities and their properties and positions - **a**: an attention mask over entities, used for identification - **w**: a continuous conditioning vector specifying which concept is being evaluated - The model outputs a single positive number. Energy is zero when the concept is satisfied and high otherwise. - A concept is satisfied when the attention mask focuses on entities that are in the correct positions (generation) and are the right entities (identification). - The energy function is a relational network, so it can accept an arbitrary number of entities. ## One Network for Generation and Recognition - A single network handles both generating a concept (moving entities in x) and identifying it (changing the attention mask over a fixed x). - Concepts learned through one mode can be applied to the other. ## Training Procedure - Training data consists of trajectories of (attention mask, state) pairs generated for each target concept. - The model sees about five demonstrations of a concept, then receives a new environment (X0) and predicts the next state (X1) and next attention mask (a). - The energy function is optimized so the correct next state and mask receive low energy, similar in spirit to variational autoencoders, which encourages compressed, useful representations. - Training covered visual, spatial, proximal, and temporal relations, plus quantification, in a 2D particle environment. ## Results - The system learned to classify and generate spatial relationships, move entities through scenes in specified ways, and judge quantities (one, two, three, or more than three) and proximity. - Joint training on generation and identification outperformed training on either operation alone. - Transfer also emerged: an energy function trained only on recognition performed well on generation without explicit training for it. ## Future Directions - Learning concepts in richer, three-dimensional environments - Integrating concepts with agent decision-making policies, since the work so far used only passive experience - Connecting concepts to language understanding

OpenAI2016-11-102 min readCurated summary

A connection between generative adversarial networks, inverse reinforcement learning, and energy-based models

Generative adversarial networks (GANs), inverse reinforcement learning (IRL), and energy-based models (EBMs) are usually studied separately, but this post argues they are closely linked. The authors show that a sample-based algorithm for maximum entropy IRL is mathematically equivalent to a GAN in which the generator's density can be evaluated and fed to the discriminator. They then argue that GAN training can be understood as training an energy-based model, and they hope making these links explicit will help researchers transfer techniques for stabilizing and scaling these methods. ## Learning Cost Functions in Generative Modeling and Control - In a GAN, the generator is trained against a cost function that a discriminator learns at the same time. - Learning cost functions has a longer history in control and reinforcement learning, mainly for imitation learning from demonstrations. - In those fields, recovering the cost that explains observed behavior is called inverse reinforcement learning or inverse optimal control. ## Equivalence Between Maximum Entropy IRL and GANs - The authors show that certain IRL methods are not just analogous to GANs but mathematically equivalent to them. - The specific match is a sample-based algorithm for maximum entropy IRL and a GAN whose discriminator also receives the generator's density as an additional input. ## Connection to Energy-Based Models - Maximum entropy IRL is a special case of an energy-based model. - Because of this, GAN training can be interpreted as a way to train energy-based models. - The paper relates this view to other recent work that connects GANs and EBMs. ## Implications for Stability and Scalability - Stability and scalability are named as major open challenges in all three areas. - The authors suggest that ideas can move between the communities once the formal connections are clear, especially methods aimed at more stable and scalable training.