Gradient Estimation For Exactly-$k$ Constraints

Ruoyan Li, Dipti Ranjan Sahu, Guy Van den Broeck, Zhe ZengAI4Science @ NeurIPS 2023

TL;DR

This paper introduces a generalized method for training machine learning models with "exactly-k" constraints, extending previous work from binary variables to continuous (Gaussian) and count (Poisson) data. This allows for more accurate and applicable models in scientific domains like chemistry where such constraints are fundamental.

What Problem Does This Paper Address?

Many real-world problems, from ensuring electrical neutrality in atoms to modeling biological cell types, require that a set of variables sum up to a specific value (an "exactly-k" constraint). Incorporating these constraints directly into machine learning models, especially those that rely on gradient-based optimization (like neural networks), is notoriously difficult. Standard methods either struggle with high variance in gradient estimates or introduce bias through approximations. While a recent method (SIMPLE) addressed this for binary variables, its applicability to other common data types remained an open question. This paper aims to fill that gap by providing a unified approach for Gaussian and Poisson variables.

Methods

The core of the paper lies in developing gradient estimators for exactly-k constraints on Gaussian and Poisson distributions. The authors achieve this by:

  • Exact Sampling: Deriving closed-form solutions for sampling from the constrained Gaussian and Poisson distributions. This means they can generate valid samples that adhere to the constraint without resorting to approximations.
  • Conditional Marginals as Proxy: Leveraging the idea of using conditional marginal distributions as a proxy for actual samples. This is a key insight from prior work, and the authors extend it by deriving closed-form expressions for these marginals for both Gaussian and Poisson cases.
  • Closed-form Expected Loss: For specific scenarios (e.g., when the model's output is directly the constrained variable and certain loss functions are used), they show that the expected loss itself can be computed in closed-form. This eliminates the need for gradient estimation altogether in these cases, leading to exact optimization.

Datasets

The paper uses synthetic datasets for evaluating the gradient estimators' bias and variance. For a real-world application, they use a dataset of metal-organic frameworks (MOFs) to predict partial charges, a task that inherently involves charge neutrality constraints.

Key Insights and Ideas

  • Universality of the Approach: The most significant insight is demonstrating that the core idea of using constraint probabilities and conditional marginals can be generalized beyond Bernoulli variables to Gaussian and Poisson distributions. This significantly broadens the applicability of constrained learning.
  • Closed-Form Solutions are Powerful: The derivation of closed-form solutions for both sampling and expected loss (in specific cases) is a major contribution. This not only simplifies the optimization process but also provides a strong theoretical foundation.
  • Conditional Marginals as Effective Proxies: The paper reinforces the effectiveness of using conditional marginals as a computationally efficient and accurate proxy for full samples, especially when exact sampling is complex.
  • Practical Impact in Chemistry: The application to MOF partial charge prediction highlights the real-world impact of these methods, showing they can solve challenging scientific problems that were previously difficult to tackle with standard ML techniques.

Key Results

  • Synthetic Experiments: The proposed gradient estimators significantly outperform random baselines in terms of bias, variance, and average error on synthetic Gaussian and Poisson data.
  • MOF Partial Charge Prediction: When applied to predicting partial charges in metal-organic frameworks, the proposed method, especially when combined with an ensemble approach, achieves state-of-the-art performance, matching or exceeding existing strong baselines. The closed-form loss function approach also yields competitive results.

Limitations and Future Work

  • Specific Loss Functions: The closed-form expected loss is derived for specific loss functions (L1/L2 for Gaussian, L2 for Poisson) and when the decoder is an identity function. Extending this to more general loss functions or complex decoder architectures would be valuable.
  • Distribution Families: While extended to Gaussian and Poisson, the framework could potentially be generalized to other continuous or discrete distributions.
  • Computational Complexity: While closed-form solutions are derived, their computational complexity for very high-dimensional problems might still be a consideration.

The authors suggest that their work provides a "cookbook" for incorporating exactly-k constraints, implying that further exploration into other distribution families and more complex model architectures is a natural next step.

Summary updated

BibTeX
@inproceedings{li2023gradient,
  author = {Ruoyan Li and Dipti Ranjan Sahu and Guy Van den Broeck and Zhe Zeng},
  title = {{Gradient Estimation For Exactly-$k$ Constraints}},
  booktitle = {AI4Science @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=zkPxoyPeva},
}
Figure