Differentiable Projection for Constrained Deep Learning

Dou Huang, Haoran Zhang, Xuan Song, Ryosuke ShibasakiarXiv 2021

Abstract: Deep neural networks (DNNs) have achieved extraordinary performance in solving different tasks in various fields. However, the conventional DNN model is steadily approaching the ground-truth value through loss backpropagation. In some applications, some prior knowledge could be easily obtained, such as constraints which the ground truth observation follows. Here, we try to give a general approach to incorporate information from these constraints to enhance the performance of the DNNs. Theoretically, we could formulate these kinds of problems as constrained optimization problems that KKT conditions could solve. In this paper, we propose to use a differentiable projection layer in DNN instead of directly solving time-consuming KKT conditions. The proposed projection method is differentiable, and no heavy computation is required. Finally, we also conducted some experiments using a randomly generated synthetic dataset and image segmentation task using the PASCAL VOC dataset to evaluate the performance of the proposed projection method. Experimental results show that the projection method is sufficient and outperforms baseline methods.

Introduction

Deep learning models are often criticized for being "black boxes." While they excel at mimicking patterns in data, they frequently ignore basic rules or physical constraints that the ground truth must follow—for instance, the requirement that the sum of parts must equal the whole, or that certain objects cannot coexist based on global image tags.

Traditionally, researchers enforce these rules using soft regularization (like L1 or L2 loss) or by solving complex Karush–Kuhn–Tucker (KKT) conditions during optimization. However, regularization is often too weak to strictly enforce constraints, and solving KKT conditions at every training step is computationally prohibitive. This paper introduces a differentiable projection layer that allows deep neural networks (DNNs) to incorporate prior knowledge in the form of linear constraints efficiently.

Methodology: The Differentiable Projection Layer

The authors propose a Differentiable Projection Layer (PDNN). Instead of treating constraints as a penalty in the loss function, they insert a layer that mathematically projects the network's raw output onto a feasible region defined by linear equalities or inequalities.

Conceptual diagram of projecting an unconstrained update into a constrained region.

As illustrated in Figure 1, the projection ensures that the network output adheres to a "feasible region." Key technical components include:

  • Linear Equality Projection: For constraints like $Ax = b$, a closed-form orthogonal projection is used.
  • Iterative Inequality Projection: For complex inequality constraints ($Ax \leq b$), the authors implement an iterative method and prove it is differentiable, allowing the network to learn through the projection.
  • Surrogate Constraints: To handle multiple constraints without massive overhead, they use a surrogate approach that combines violated constraints into a single direction for the projection step.

Experimental Evaluation

The researchers evaluated their approach on two distinct types of data:

  1. Synthetic Dataset: A randomly generated dataset with 64-dimensional inputs mapped to 8-dimensional outputs, subject to random linear constraints. The PDNN achieved a Mean Squared Error (MSE) of 0.02093, significantly lower than the standard DNN's 0.02279.
  2. PASCAL VOC 2012: A standard image segmentation benchmark. In a weakly supervised setting, image-level tags were used to create constraints for pixel-level predictions (e.g., pixels belonging to classes not in the tags must be zero).

Key Results

On the PASCAL VOC task, the PDNN improved the mean Intersection over Union (mIoU) from 48.07 to 49.20. Beyond numerical gains, the projection layer successfully suppressed "impossible" pixels.

Qualitative comparison of image segmentation results with and without the projection layer.

As shown in Figure 5, the projection method leads to much cleaner segmentation masks. For example, it effectively removed random "car" pixel predictions in images where global tags indicated only a "bus" was present.

Discussion and Insights

  • Prior Knowledge as Supervision: Constraints act as a "free" source of supervision. By enforcing known truths about the world, the model can be guided to better solutions even when labeled data is sparse or "weak."
  • Efficiency vs. Perfection: The authors found that finding the absolute closest point in the feasible region (the KKT solution) isn't strictly necessary. Simply moving the output closer to the feasible region provides a sufficient gradient for effective learning.
  • Limitations: The current framework is limited to linear constraints. Many real-world physical constraints (e.g., in fluid dynamics) are non-linear, which remains a subject for future work. Additionally, while more efficient than KKT solvers, iterative projection still adds some computational overhead to training.

Summary updated

BibTeX
@misc{huang2021differentiable,
  author = {Dou Huang and Haoran Zhang and Xuan Song and Ryosuke Shibasaki},
  title = {{Differentiable Projection for Constrained Deep Learning}},
  year = {2021},
  eprint = {2111.10785},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2111.10785},
}
Figure