Differentiable Implicit Layers

Andreas Look, Simona Doneva, Melih Kandemir, Rainer Gemulla, Jan PetersarXiv 2020

Abstract

In this paper, we introduce an efficient backpropagation scheme for non-constrained implicit functions. These functions are parametrized by a set of learnable weights and may optionally depend on some input, making them suitable as learnable layers in a neural network. We demonstrate our scheme on two primary applications: (i) neural ODEs using the implicit Euler method, and (ii) system identification in model predictive control (MPC). Our approach overcomes the scalability limitations of previous implicit layer methods by combining the Implicit Function Theorem (IFT) with the Conjugate Gradient (CG) method.

Introduction: The Implicit Bottleneck

Standard deep learning architectures rely on "explicit" layers, where inputs are transformed into outputs through a fixed sequence of operations like matrix multiplications and activation functions. However, many complex systems in physics and engineering are naturally described by "implicit" relationships—where the output is defined as the solution to an optimization problem or an algebraic equation.

While implicit layers offer greater modeling flexibility, they have historically faced a major scalability hurdle. General methods for differentiating through these layers require calculating and inverting large Jacobian or Hessian matrices, a process with a computational complexity of $O(D_y^3)$. This makes them prohibitively expensive for high-dimensional outputs.

Methodology: Differentiable Implicit Layers (DIL)

We propose a framework where a layer's output $y$ is defined as the solution to an optimization problem: $y = \text{argmin}_u f(u; x, \theta)$. To make this layer trainable, we introduce several key innovations:

  1. Black-box Forward Pass: The framework allows the use of any existing numerical solver to find the optimal $y$. The solver is treated as a black box, enabling the use of specialized, non-differentiable tools for the forward pass.
  2. Bi-Level IFT: Instead of "unrolling" the solver's iterations—which is memory-intensive—we apply the Implicit Function Theorem to calculate gradients directly at the solution point.
  3. CG-Accelerated Backpropagation: To avoid the $O(D_y^3)$ bottleneck of matrix inversion, we solve the necessary linear systems using the Conjugate Gradient (CG) method. This approach relies on Vector-Jacobian Products (VJPs), which are efficiently computed by modern autodiff libraries, bypassing the need for explicit Hessian inversion.
Visualization of an implicit layer's optimization landscape. The layer's output is defined as the argmin of a residual function, shown here with optimization trajectories converging toward a target.

Experimental Evaluation

We evaluated DIL across several benchmarks, including synthetic time series (Van der Pol oscillator), high-dimensional motion capture data (CMU Walking dataset), and classic control problems (Cart Pole swing-up).

Stability and Accuracy

By applying DIL to Neural ODEs using the Implicit Euler method, we achieved significantly higher stability for "stiff" dynamical systems compared to standard explicit solvers. On the Van der Pol and CMU Walking tasks, the DIL approach achieved lower Mean Squared Error (MSE) than standard Neural ODE implementations like DOPRI5.

Scalability and Speed

A critical result of our work is the computational efficiency gained through the CG-accelerated backward pass. As shown in our Neural ODE experiments, our method maintains a near-constant backward pass time even as the dimensionality of the system increases, whereas naive IFT implementations scale poorly.

Computational time vs. Neural ODE dimension. The proposed IFT_CG method (blue) maintains near-constant time as dimensionality increases, significantly outperforming the naive IFT approach (orange).

Conclusion

Differentiable Implicit Layers provide a memory-efficient and scalable way to incorporate optimization-based logic into neural networks. By decoupling the solver from the gradient calculation and utilizing CG-acceleration, we enable the training of high-dimensional implicit models that were previously computationally infeasible. Future work will explore preconditioning techniques to further accelerate the Conjugate Gradient method for even more complex optimization landscapes.

Summary updated

BibTeX
@misc{look2020differentiable,
  author = {Andreas Look and Simona Doneva and Melih Kandemir and Rainer Gemulla and Jan Peters},
  title = {{Differentiable Implicit Layers}},
  year = {2020},
  eprint = {2010.07078},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2010.07078},
}
Figure