On Differentiating Parameterized Argmin and Argmax Problems with Application to Bi-level Optimization

Stephen Gould, Basura Fernando, Anoop Cherian, Peter Anderson, Rodrigo Santa Cruz, Edison GuoarXiv 2016

Abstract: Some recent works in machine learning and computer vision involve the solution of a bi-level optimization problem. Here the solution of a parameterized lower-level problem binds variables that appear in the objective of an upper-level problem. The lower-level problem typically appears as an argmin or argmax optimization problem. Many techniques have been proposed to solve bi-level optimization problems, including gradient descent, which is popular with current end-to-end learning approaches. In this technical report we collect some results on differentiating argmin and argmax optimization problems with and without constraints and provide some insightful motivating examples.

1. Introduction

In modern deep learning, computational layers are typically defined by explicit mathematical operations. However, a more powerful paradigm involves layers defined as the solution to an optimization problem—specifically, finding a vector $y$ that minimizes or maximizes a cost function $f(x, y)$ parameterized by $x$. To integrate such layers into end-to-end learning pipelines via backpropagation, one must compute the gradient of the optimization result with respect to the input parameters. This report provides a comprehensive mathematical framework for differentiating through these "argmin" and "argmax" problems.

Bi-level optimization naturally arises in scenarios such as hyper-parameter tuning, image denoising, and strategic decision-making (leader-follower games). The primary challenge is that the lower-level optimization often lacks a closed-form solution, rendering standard automatic differentiation inapplicable. By leveraging implicit differentiation, we bridge this gap.

2. Methodology

The core approach relies on implicit differentiation of the optimality conditions. For an unconstrained problem, if $y = g(x)$ is a stationary point of $f(x, y)$, then the gradient with respect to $y$ must be zero: $\nabla_y f(x, g(x)) = 0$. By differentiating this condition with respect to $x$, we can derive the relationship between changes in the input $x$ and the resulting optimal output $y$.

  • Unconstrained Problems: The derivative is given by $g'(x) = -f_{XY} / f_{YY}$ for scalars, or by inverting the Hessian matrix $\nabla^2_{yy} f$ in the vector case.
  • Equality Constraints: For problems subject to $Ay=b$, we employ null-space projection or Lagrangian multipliers to determine the gradient.
  • Inequality Constraints: We utilize log-barrier functions from interior-point methods to approximate inequality constraints. This transforms the constrained problem into a smooth, unconstrained approximation suitable for differentiation.
Visualization of a non-convex 1D function slice and the resulting argmin/argmax paths g(x) and their derivatives g'(x).

3. Key Insights

Several important properties emerge from this framework:

  1. Optimization Agnosticism: The gradient depends only on the final solution and the second-order derivatives of the objective function, not on the specific algorithm (e.g., Newton's method vs. Gradient Descent) used to find it.
  2. Stationary Point Sufficiency: The mathematical derivation holds for any stationary point—including local minima, maxima, or saddle points—making it applicable to non-convex landscapes, provided care is taken regarding discontinuities.
  3. Invariance: The optimal point and its gradient are invariant under monotonic transformations of the objective function.
  4. Computational Bottleneck: The primary cost is the inversion of the Hessian matrix, which scales as $O(N^3)$ with the dimensionality of the lower-level variable $y$.

4. Experimental Evaluation

We demonstrate the utility of these gradients through a series of synthetic tasks, including a bi-level optimization problem involving a Softmax classifier. The goal is to train classifier parameters so that the most likely feature vectors (the argmax) for each class align with specific target locations.

Likelihood surface before and after a negative gradient step, demonstrating the movement of the optimal point x*.

As shown in Figure 4, the derived gradients successfully guide the upper-level objective toward convergence. In our tests, the system reached a precision of $10^{-9}$ in fewer than 100 iterations. The visual evidence confirms that the gradients correctly push the maximum likelihood points through both equality and inequality constraints.

5. Discussion and Limitations

While powerful, the method has limitations. The $O(N^3)$ cost of Hessian inversion necessitates approximations (such as diagonal scaling) for high-dimensional problems like image processing. Furthermore, the requirement for twice-differentiable objectives precludes direct application to non-smooth functions (e.g., $L_1$ regularization) without smooth approximations. Future work will explore "warm-start" techniques and the impact of using approximate solutions to the lower-level problem during the learning process.

Summary updated

BibTeX
@misc{gould2016differentiating,
  author = {Stephen Gould and Basura Fernando and Anoop Cherian and Peter Anderson and Rodrigo Santa Cruz and Edison Guo},
  title = {{On Differentiating Parameterized Argmin and Argmax Problems with Application to Bi-level Optimization}},
  year = {2016},
  eprint = {1607.05447},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1607.05447},
}
Figure