Learning with Statistical Equality Constraints

Aneesh Barthakur, Luiz F. O. Chamon

Abstract

While constrained machine learning typically focuses on inequalities, many critical requirements—such as group fairness and physical laws—are naturally expressed as equalities. This paper presents a comprehensive generalization theory and a practical primal-dual algorithm for learning with statistical equality constraints. By leveraging the properties of overparameterized models, the authors demonstrate that the duality gap can be effectively bridged even in non-convex settings, providing a robust framework for enforcing "hard" constraints in deep learning.

Introduction

In modern machine learning, optimizing for accuracy alone is often insufficient. Models must frequently adhere to fairness metrics, robustness criteria, or physical laws. Traditionally, these requirements are handled via penalty terms (e.g., $\text{Loss} + \lambda \cdot \text{Penalty}$), which require manual tuning of hyperparameters, or via inequality constraints. However, equality constraints—where a penalty must be exactly zero—have historically been avoided due to their mathematical "brittleness."

Unlike inequalities, the feasible sets for equalities have no interior; satisfying them is akin to landing a dart exactly on a microscopic line rather than anywhere inside a large circle. This work addresses this gap by providing theoretical justification and a scalable algorithm for direct equality-constrained learning, proving that overparameterized models can effectively navigate these constraints.

Theoretical Framework

The authors bridge the gap between theory and practice through two primary theoretical contributions:

  1. Generalization Theory: The authors derive a new generalization bound (Theorem 3.1) specifically for equality-constrained problems. This bound shows that the error depends on four critical factors: constraint sensitivity (measured by Lagrange multipliers), the smoothness of the model, the model's capacity (parametrization richness), and the sample size.
  2. Functional Duality: A key finding is that for "rich" hypothesis classes, such as deep neural networks, a form of "strong duality" holds. This suggests that even in non-convex settings, we can solve a complex constrained problem by instead solving a simpler saddle-point problem using its Lagrangian.

The Primal-Dual Algorithm

The proposed Primal-Dual Constrained Learning algorithm operationalizes these theories by alternating between two optimization steps:

  • Primal Step: The model weights ($\theta$) are updated to minimize the current Lagrangian.
  • Dual Step: The dual variables (Lagrange multipliers) are updated based on the magnitude and direction of constraint violations.

Unlike inequality constraints, which typically use a max(0, ...) update to keep multipliers non-negative, equality constraints allow these variables to be positive or negative. This allows the algorithm to exert the necessary "push and pull" to hit an exact target value.

Experimental Evaluation

The researchers evaluated their approach across three distinct domains to demonstrate its versatility:

1. Fairness (COMPAS)

Using the COMPAS recidivism dataset, the authors enforced demographic parity across different racial groups. The equality-constrained formulation achieved the lowest disparity between groups compared to unconstrained or "slack" inequality versions, maintaining high accuracy while ensuring strict fairness.

2. Physics-Informed ML (Convection BVPs)

In solving synthetic Convection Boundary Value Problems (BVP), the proposed method (P-BVP) significantly outperformed standard Physics-Informed Neural Networks (PINNs). For challenging convection parameters ($\beta=50$), where PINNs often struggle with stability and show relative errors of ~56%, the constrained approach reduced error to ~30.7%.

3. Interpolating Classifiers (CIFAR-10/100)

The algorithm successfully trained ResNet18 models to perfectly fit every class on the training set (interpolation) while maintaining competitive test accuracy. This demonstrated the algorithm's ability to handle hundreds of simultaneous equality constraints (one per class) in a high-dimensional setting.

Key Insights

  • Overparameterization as a Feature: In classical optimization, non-convexity usually breaks duality. However, this work shows that having a "rich" hypothesis class actually helps "heal" the duality gap, making constrained optimization viable for deep networks.
  • Equalities vs. "Slack" Inequalities: Researchers often approximate an equality $h(x) = 0$ with two inequalities $-\epsilon \le h(x) \le \epsilon$. The authors demonstrate that direct equality constraints are more theoretically sound and practically simpler, as they remove the need to tune the "slack" parameter $\epsilon$.
  • Dual Variables as Diagnostics: In CIFAR experiments, the authors observed a 0.89 correlation between learned dual variables and the test error of a class. This suggests that Lagrange multipliers act as a "difficulty meter," identifying which classes are hardest for the model to learn.

Limitations and Future Work

Despite its success, the approach has limitations. The theory for equalities requires stricter regularity conditions than inequalities, requiring the model to be "rich" enough to satisfy constraints under small perturbations. Additionally, there is a computational overhead; for example, CIFAR-100 experiments took nearly twice as long as standard training. Finally, while the "last iterate" of the model works well in practice, developing more robust methods for "primal recovery" in non-convex settings remains an open area for research.

Summary updated

BibTeX
@inproceedings{barthakur2025learning,
  author = {Aneesh Barthakur and Luiz F. O. Chamon},
  title = {{Learning with Statistical Equality Constraints}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=oDA6t2RaFC},
}
Figure