Reparameterizable Subset Sampling via Continuous Relaxations

Sang Michael Xie, Stefano Ermon

Abstract

Many machine learning tasks require sampling a subset of items from a collection based on a parameterized distribution. The Gumbel-softmax trick can be used to sample a single item, and allows for low-variance reparameterized gradients with respect to the parameters of the underlying distribution. However, stochastic optimization involving subset sampling is typically not reparameterizable. To overcome this limitation, we define a continuous relaxation of subset sampling that provides reparameterization gradients by generalizing the Gumbel-max trick. We use this approach to sample subsets of features in an instance-wise feature selection task for model interpretability, subsets of neighbors to implement a deep stochastic k-nearest neighbors model, and sub-sequences of neighbors to implement parametric t-SNE by directly comparing the identities of local neighbors. We improve performance in all these tasks by incorporating subset sampling in end-to-end training.

Introduction

In deep learning, models often need to make discrete choices, such as selecting the most important words in a sentence or identifying the nearest neighbors of a data point. While the Gumbel-Softmax trick facilitates differentiable selection of a single item, picking a subset of $k$ items without replacement presents a significant challenge due to the combinatorial explosion of possible subsets.

Previous approaches often relied on high-variance reinforcement learning techniques like REINFORCE or independent sampling methods that could result in redundant selections. This work introduces a "relaxed" version of subset sampling that is computationally efficient and compatible with standard backpropagation, enabling end-to-end training for subset-selection tasks.

Methods: Relaxed Subset Sampling

The proposed method bridges the gap between discrete subset selection and continuous optimization through three primary components:

  1. Gumbel-max Extension: The authors utilize Weighted Reservoir Sampling (WRS), a standard algorithm for picking $k$ items without replacement. They demonstrate that by adding Gumbel noise to the logits (scores) of each item and selecting the top $k$ values, they can exactly replicate the WRS distribution.
  2. Continuous Relaxation: Because the "top-$k$" operation is non-differentiable, it is replaced with a RelaxedTopK function. This function employs a sequence of $k$ softmax operations to produce "relaxed" $k$-hot vectors, where values range between 0 and 1 but sum to $k$.
  3. Consistency Proof: A key theoretical contribution is Theorem 1, which proves the relaxation is "consistent." This ensures that even at higher temperatures, the items with the highest scores correspond to the highest values in the relaxed output, preserving the ranking signal during training.
Algorithm for Relaxed Subset Sampling.

Experimental Evaluation

The method was evaluated across several domains, including sentiment analysis (IMDB), image classification (MNIST, CIFAR-10), and text clustering (20 Newsgroups).

Model Explanations (L2X)

On the IMDB word-selection task for "Learning to Explain" (L2X), the method achieved 91.7% post-hoc accuracy, outperforming the previous state-of-the-art (90.7%). Crucially, it resolved the redundancy issue where previous models would occasionally select the same word multiple times.

Stochastic k-NN and Speed

The method matched standard CNN performance on MNIST (99.3%) and improved CIFAR-10 accuracy by 0.6% over sorting-based relaxations. In terms of efficiency, the algorithm scales at $O(km)$, making it significantly faster than methods like NeuralSort ($O(m^2)$). In benchmarks, it was over 30x faster when selecting 5 neighbors from 5,000 candidates.

Dimensionality Reduction (RSS-SNE)

The authors introduced RSS-SNE, a parametric version of t-SNE that directly compares neighbor identities. This approach proved more robust than matching exact distance distributions. As shown in the results table, RSS-SNE consistently achieved higher "trustworthiness" scores—a metric for local structure preservation—compared to standard parametric t-SNE across different embedding dimensions ($d$).

Trustworthiness scores for RSS-SNE compared to parametric t-SNE on MNIST and 20 Newsgroups.

Discussion and Limitations

The algorithm serves as a "drop-in" replacement for any neural network component requiring hard top-$k$ selection. By treating subset sampling as a sequence of selections, the model preserves the relative importance of items.

However, some limitations remain. The method samples from a specific family of distributions based on WRS, which may not cover all possible subset probability distributions. Additionally, while Theorem 1 guarantees consistency for temperatures $t \ge 1$, very low temperatures ($0 < t < 1$) could theoretically lead to inconsistencies, though this was not observed in practice. Future work may extend these relaxations to more complex combinatorial structures like spanning trees or matchings.

Summary updated

BibTeX
@inproceedings{xie2019reparameterizable,
  author = {Sang Michael Xie and Stefano Ermon},
  title = {{Reparameterizable Subset Sampling via Continuous Relaxations}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2019},
  url = {https://openreview.net/forum?id=yzMy8CNx61x},
}
Figure