techlist.io

Gans

2 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-07-084 min readCurated summary

Glow: Better reversible generative models

# Glow: Reversible Generative Models with Invertible 1x1 Convolutions Glow is a reversible, flow-based generative model that simplifies the earlier RealNVP architecture by replacing fixed channel permutations with learned invertible 1x1 convolutions. The change yields significant log-likelihood gains on standard benchmarks while producing realistic high-resolution images and supporting efficient sampling. The authors argue that flow-based models, despite receiving far less attention than GANs and VAEs, offer exact inference, parallel synthesis, and a useful latent space for manipulating data. ## Why Flow-Based Models Are Worth Considering Generative models learn the structure of a dataset so they can produce outputs that resemble it, with applications in speech synthesis, text analysis, semi-supervised learning, and model-based control. Flow-based models, an extension of NICE and RealNVP, offer several advantages over alternatives: - **Exact inference and likelihood:** VAEs only approximate latent variables, and GANs have no encoder at all. Reversible models compute latents exactly and optimize the true log-likelihood rather than a lower bound. - **Efficient inference and synthesis:** Autoregressive models like PixelCNN are reversible but hard to parallelize for sampling. Flow-based models parallelize well for both directions. - **Useful latent spaces:** Reversible models and VAEs allow interpolation and meaningful edits of existing datapoints, which GANs and autoregressive models make difficult. - **Memory savings:** Gradients in reversible networks need memory constant in depth rather than linear, per the RevNet work. ## Benchmark Results Glow improves on RealNVP, the previous best flow-based result, on most benchmarks, measured in bits per dimension (lower is better): - CIFAR-10: 3.49 (RealNVP) vs. 3.55 (Glow), a slight regression - ImageNet 32x32: 4.28 vs. 4.09 - ImageNet 64x64: 3.98 vs. 3.81 - LSUN bedroom: 2.72 vs. 2.38 - LSUN tower: 2.81 vs. 2.46 - LSUN church outdoor: 3.08 vs. 2.67 Sampling a 256x256 image takes about 130ms on an NVIDIA 1080 Ti. Sampling from a reduced-temperature model (scaling latent standard deviation by 0.7) gives higher-quality samples. ## Latent Space Applications - **Interpolation:** Encoding two real face images and sampling intermediate points produces smooth transitions. Because the inputs are arbitrary faces rather than model samples, this suggests the model covers the full target distribution. - **Attribute manipulation:** The model trains without labels. Afterward, averaging latent encodings of inputs with and without an attribute (such as blonde hair) yields a direction vector that can shift new inputs toward that attribute. This needs only a small labeled set and no retraining, unlike GAN-based or Cycle-GAN approaches. ## Architectural Changes from RealNVP RealNVP alternates checkerboard-masked layers with channel-wise masked layers. Glow removes the checkerboard layers and changes the channel-wise layers in two ways: - **Learned 1x1 convolutions replace fixed permutations.** RealNVP's channel-wise coupling splits inputs into halves that update each other in a rigid bipartite pattern. Replacing the fixed reversal with a fixed shuffle improved performance, and learning the permutation improved it further. Since a permutation is a square linear transformation, it can be expressed as a 1x1 convolution and optimized with gradient descent. The weights start as a random rotation matrix and are efficiently computed via LU decomposition. - **Activation normalization replaces batch normalization.** This layer applies a learned per-channel shift and scale, initialized from a first minibatch. It allows a minibatch size of 1 for large images and lets the model scale up. ## Scaling Up Gradient checkpointing and other optimizations make training feasible at larger scale. The demo model was trained with Horovod across 5 machines of 8 GPUs each and has over 100 million parameters. ## Open Directions The authors identify two areas for future work: - **Likelihood competitiveness:** Autoregressive models and VAEs still score better on log-likelihood, but they sacrifice efficient sampling and exact inference, respectively. Combining these model families could capture the strengths of each. - **Efficiency:** The face model uses roughly 200M parameters and about 600 convolution layers, which is expensive to train. Shallower models learn long-range dependencies poorly, so self-attention or progressive training could reduce compute cost. Code and the paper are available on GitHub for anyone who wants to build on the work.