Revisiting Score Function Estimators for k-Subset Sampling.

Klas Wijk, Ricardo Vinuesa, Hossein Azizpour

Introduction

Selecting exactly $k$ items from a set of $n$ is a fundamental challenge in machine learning, appearing in tasks such as feature selection, sensor placement, and sparse modeling. Because subset selection is a discrete operation, it is inherently non-differentiable, posing a significant hurdle for gradient-based optimization.

Historically, researchers have circumvented this by using "relaxed" sampling techniques, such as the Gumbel-Softmax trick, which approximate discrete choices with continuous ones. However, these relaxations introduce bias into the gradients and create a discrepancy between training (where "soft" subsets are used) and inference (where "hard" subsets are required). This paper revitalizes the Score Function Estimator (SFE), providing an unbiased, exact, and efficient alternative for $k$-subset sampling.

Methodology: SFESS

The authors introduce SFESS (Score Function Estimator for $k$-Subset Sampling). Unlike pathwise gradient estimators that require differentiable relaxations, SFEs (like REINFORCE) operate directly on discrete samples.

Comparison of gradient estimation strategies: score function, pathwise, and relaxed sampling.

The primary obstacles for SFEs in combinatorial spaces are computational complexity and high variance. SFESS addresses these through two key innovations:

  1. The DFT Trick: Calculating the probability of a specific $k$-subset is typically a combinatorial challenge. The authors observe that this probability follows a Poisson binomial distribution. By utilizing the Discrete Fourier Transform (DFT), they reduce the complexity of computing the log-probability gradient (the "score") to $O(n \log n)$, making it highly efficient for GPU acceleration.
  2. Variance Reduction (SFESS-V): To mitigate the high variance typical of SFEs, the authors employ control variates. By using multiple samples to establish a baseline, SFESS-V achieves a stable training signal that rivals or exceeds the stability of biased relaxed methods.

Experimental Setup

The efficacy of SFESS-V was evaluated on three image-based feature selection benchmarks:

  • MNIST: Handwritten digit classification.
  • Fashion-MNIST: Clothing item classification.
  • KMNIST: Kuzushiji (Japanese cursive) character classification.

In these tasks, the models were constrained to select exactly $k=30$ pixels to either reconstruct the input image or perform classification. This setup tests the estimator's ability to identify the most informative discrete features under a strict budget.

Results and Analysis

Empirical results demonstrate that while biased methods like Straight-Through Gumbel-Softmax (STGS) may show faster initial progress, the unbiased nature of SFESS-V allows it to achieve superior final performance.

Performance comparison (PSNR and Accuracy) across MNIST, Fashion MNIST, and KMNIST datasets.

Key findings include:

  • Accuracy and Reconstruction: On MNIST, SFESS-V reached 92.1% accuracy, outperforming GS and STGS (89.8%). In reconstruction tasks, SFESS-V consistently achieved the highest Peak Signal-to-Noise Ratio (PSNR) across all datasets, notably reaching 17.805 on Fashion-MNIST.
  • Computational Efficiency: Contrary to the assumption that exact methods are slower, SFESS-V was approximately 40% faster per epoch than Gumbel-Softmax baselines. This efficiency stems from the hardware-friendly nature of the DFT compared to the sequential operations required by top-k relaxations.
  • Training-Inference Consistency: By using exact discrete subsets during training, SFESS-V eliminates the "gap" between training and deployment, leading to more robust models.

Conclusion

SFESS-V demonstrates that score function estimators, when combined with efficient computation and variance reduction, are powerful tools for combinatorial optimization in deep learning. While early-stage convergence can be slower than relaxed methods, the eventual gains in accuracy and the benefit of unbiased gradients make it a compelling choice. Future work may explore hybrid approaches that leverage the "warm start" of relaxed gradients followed by the high-precision refinement of SFESS.

Summary updated

BibTeX
@inproceedings{wijk2024revisiting,
  author = {Klas Wijk and Ricardo Vinuesa and Hossein Azizpour},
  title = {{Revisiting Score Function Estimators for k-Subset Sampling.}},
  booktitle = {Differentiable Almost Everything @ ICML},
  year = {2024},
  url = {https://openreview.net/forum?id=opr1ijTcj7},
}
Figure