Abstract
Ensuring neural networks adhere to domain-specific constraints is crucial foraddressing safety and ethical concerns while also enhancing predictionaccuracy. Despite the nonlinear nature of most real-world tasks, existingmethods are predominantly limited to affine or convex constraints. We introduceENFORCE, a neural network architecture that guarantees predictions to satisfynonlinear constraints exactly. ENFORCE is trained with standard unconstrainedgradient-based optimizers (e.g., Adam) and leverages autodifferentiation andlocal neural projections to enforce any $\mathcal{C}^1$ constraint to arbitrarytolerance $\epsilon$. We build an adaptive-depth neural projection (AdaNP)module that dynamically adjusts its complexity to suit the specific problem andthe required tolerance levels. ENFORCE guarantees satisfaction of equalityconstraints that are nonlinear in both inputs and outputs of the neural networkwith minimal (and adjustable) computational cost.