Categorical Reparameterization with Gumbel-Softmax

Eric Jang, Shixiang Gu, Ben Poole

Introduction

Training neural networks with discrete latent variables has historically been a significant challenge in deep learning. While backpropagation is the standard for training differentiable models, it cannot be directly applied to stochastic nodes that produce discrete samples. Traditional approaches like score function estimators (e.g., REINFORCE) suffer from high variance and slow convergence, while exact marginalization becomes computationally prohibitive as the number of categories increases. This paper introduces the Gumbel-Softmax, a continuous distribution that provides a differentiable relaxation of categorical sampling.

The Gumbel-Softmax Estimator

The authors propose a method to bridge the gap between discrete and continuous variables using two primary components: the Gumbel-Max trick and a softmax relaxation.

  1. The Gumbel-Max Trick: This technique allows for sampling from a categorical distribution by adding Gumbel-distributed noise to the logits and applying an argmax operation. However, argmax is non-differentiable.
  2. Softmax Relaxation: By replacing the argmax with a softmax function, the operation becomes differentiable. A temperature parameter ($\tau$) controls the smoothness of the resulting vector.
Effect of temperature $\tau$ on Gumbel-Softmax samples and expectations. As $\tau \to 0$, the samples become nearly one-hot.

At high temperatures, the output is smooth and approaches a uniform distribution. As the temperature is annealed toward zero, the Gumbel-Softmax distribution converges to a one-hot categorical distribution. This allows gradients to flow through the sample back to the model's parameters via the reparameterization trick. Additionally, the Straight-Through (ST) Gumbel-Softmax variant uses discrete one-hot vectors in the forward pass while maintaining the differentiable Gumbel-Softmax gradient for the backward pass.

Experimental Evaluation

The proposed method was evaluated primarily on the binarized MNIST dataset, a standard benchmark for stochastic and discrete latent models. The experiments focused on Variational Autoencoders (VAEs) and Stochastic Belief Networks (SBNs).

Key Insights

  • Annealing Strategy: Starting with a high temperature allows for broad exploration of the parameter space, while gradually lowering it enables the model to settle into discrete categorical choices.
  • Efficiency in Semi-Supervised Learning: Gumbel-Softmax bypasses the need to sum over all possible classes for unlabeled data. For a model with 100 categories, this resulted in a 9.9x speedup compared to standard marginalization without sacrificing accuracy.
  • Bias-Variance Tradeoff: While Gumbel-Softmax is a biased estimator, its significantly lower variance compared to unbiased methods like REINFORCE often leads to superior training stability and faster convergence.

Results

The Gumbel-Softmax estimator consistently matched or outperformed state-of-the-art estimators such as MuProp and DARN across various tasks.

Training curves for Bernoulli and Categorical VAEs comparing Gumbel-Softmax against other gradient estimators.

As shown in the training curves, Gumbel-Softmax (and its Straight-Through variant) achieves lower negative log-likelihood (better performance) more rapidly than competing methods. Its versatility across both binary (Bernoulli) and multi-class (Categorical) latent variables makes it a robust choice for diverse neural architectures.

Limitations and Future Work

Despite its advantages, the Gumbel-Softmax is sensitive to the choice of temperature $\tau$ and the specific annealing schedule. Extremely high temperatures lead to poor approximations, while extremely low temperatures can cause vanishing gradients. Furthermore, as a continuous relaxation, there may be a discrepancy between training-time behavior and discrete test-time inference. Future research may explore automated or learned annealing schedules to optimize these trade-offs dynamically.

Summary updated

BibTeX
@inproceedings{jang2017categorical,
  author = {Eric Jang and Shixiang Gu and Ben Poole},
  title = {{Categorical Reparameterization with Gumbel-Softmax}},
  booktitle = {International Conference on Learning Representations},
  year = {2017},
  url = {https://openreview.net/forum?id=rkE3y85ee},
}
Figure