MaCow: Masked Convolutional Generative Flow

Xuezhe Ma, Xiang Kong, Shanghang Zhang, Eduard H. Hovy

In the world of deep generative modeling, researchers often face a classic trade-off between Flow-based models (like Glow) and Autoregressive models (like PixelCNN). Flow-based models are attractive because they allow for exact log-likelihood computation and efficient, parallel sampling. However, their ability to model complex data distributions—known as density estimation—has historically lagged behind. Conversely, autoregressive models are the gold standard for density estimation but are notoriously slow to sample because they generate data one element at a time.

MaCow (Masked Convolutional Generative Flow) introduces a novel architecture that bridges this gap. By using masked convolutions to capture local spatial dependencies more effectively than previous methods, MaCow combines the efficiency of flow-based models with the expressive power of autoregressive components.

Methods: The Masked Convolutional Flow

The core innovation of MaCow is the Masked Convolutional Flow. Current flow models struggle because they rely heavily on $1 \times 1$ convolutions and coupling layers, which are limited in how they model spatial dependencies. MaCow injects the "local context" strengths of autoregressive models into the "parallel efficiency" framework of flows through several key mechanisms:

  1. Masked Convolutions: Instead of the standard $1 \times 1$ invertible convolutions used in Glow, MaCow uses small "masked" kernels (e.g., $2 \times 5$). These masks ensure that the computation remains a valid "flow"—meaning the transformation is bijective and the Jacobian determinant is easy to calculate—while allowing each pixel to depend on a local neighborhood of previously processed pixels.
  2. Rotational Ordering: To ensure the model eventually sees the entire image and avoids blind spots, the authors stack multiple layers with different mask orientations (Top-Down, Bottom-Up, Left-Right, Right-Left). This allows the receptive field to grow quickly across the image.
Illustration of masked convolutions with rotational ordering (Top-Down, Bottom-Up, Left-Right, Right-Left) to capture local spatial dependencies.
  1. Fine-grained Multi-Scale Architecture: Traditional flows (like RealNVP) use a "squeeze" operation that halves the spatial dimensions and doubles the channel dimensions at each level. MaCow introduces a more gradual, fine-grained split (e.g., splitting out $1/M$ of the dimensions instead of $1/2$), which improves performance and allows for deeper hierarchies without a massive increase in parameters.
  2. Variational Dequantization: To handle the discrete nature of image pixels (0-255) in a continuous flow framework, MaCow employs variational dequantization, adding learned noise to the data to make the distribution smoother and easier to model.

Key Insights and Results

By restricting connectivity to a small masked kernel rather than a full autoregressive chain, MaCow achieves a "sweet spot." It is more expressive than a $1 \times 1$ convolution but much more stable and faster to train than a full autoregressive flow. Furthermore, the masked convolution reduces synthesis complexity from quadratic to linear, making high-resolution synthesis practical.

MaCow was evaluated on standard image benchmarks, including low-resolution datasets like CIFAR-10 and downsampled ImageNet, as well as high-resolution datasets like LSUN and CelebA-HQ.

High-resolution bedroom images generated by MaCow.
  • Density Estimation: On CIFAR-10, MaCow achieved a score of 3.16 bits/dim, significantly better than Glow (3.35) and narrowing the gap with the state-of-the-art autoregressive model, PixelSNAIL (2.85).
  • High-Resolution Performance: MaCow consistently outperformed Glow across all LSUN categories and CelebA-HQ. For example, on LSUN bedroom, it improved the negative log-likelihood from 1.20 to 0.98 bits/dim.
  • Sampling Speed: While MaCow is about 7.3x slower than Glow due to the sequential nature of the masked convolution, it is roughly 400x faster than other autoregressive flow variants like MAF. This makes it a highly competitive choice for applications requiring both quality and speed.

Limitations and Future Work

While MaCow significantly narrows the performance gap, it still does not completely match the density estimation of the very best (and slowest) autoregressive models. Additionally, although sampling complexity is linear, it remains partially sequential; for extremely large images, this could become a bottleneck compared to fully parallel flows.

Future directions include extending MaCow to other data types, such as text, and exploring its combination with variational inference to learn more meaningful low-dimensional latent representations.

Summary updated

BibTeX
@inproceedings{ma2019macow,
  author = {Xuezhe Ma and Xiang Kong and Shanghang Zhang and Eduard H. Hovy},
  title = {{MaCow: Masked Convolutional Generative Flow}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=cMEatzFWU7},
}
Figure