Port-Hamiltonian Approach to Neural Network Training

Stefano Massaroli, Michael Poli, Federico Califano, Angela Faragasso, Jinkyoo Park, Atsushi Yamashita, Hajime Asama

This paper, "Port-Hamiltonian Approach to Neural Network Training," presents a fascinating bridge between classical physics, control theory, and modern deep learning. Instead of viewing neural network training as a series of discrete mathematical steps, the authors propose treating the optimization process as a continuous physical system.

TL;DR

The authors propose a novel framework where neural network weights are updated via continuous-time Port-Hamiltonian (PH) dynamics rather than discrete steps like SGD. By treating the loss function as the "energy" of a physical system, they provide a physics-based guarantee that the network will naturally "drain" its energy until it settles into a minimum.

What Problem Does This Paper Address?

Standard neural network training relies on discrete optimization methods like Stochastic Gradient Descent (SGD) or Adam. While effective, these methods have limitations:

  1. Lack of Optimality Guarantees: In non-convex landscapes, discrete steps don't always guarantee convergence to a stable minimum.
  2. Saddle Points: Optimizers often get "stuck" or slow down significantly near saddle points.
  3. The Discrete-Continuous Gap: While recent "Neural ODEs" made network architectures continuous, the training process remained discrete.

The authors argue that by moving to a continuous-time framework rooted in physics, we can gain better theoretical insights and more robust convergence properties.

Methods

The core innovation is the Port-Hamiltonian Neural Network (PHNN). Here is how it works:

  • Loss as Energy: The objective function (loss) is defined as the Hamiltonian ($\mathcal{H}$) of a fictitious mechanical system.
  • State Representation: The "state" of the system consists of the network weights ($\vartheta$) and their fictitious "momenta" ($\omega$). This is similar to adding a momentum term in standard optimizers but formulated as a physical property.
  • The PH Equation: The parameters evolve according to a specific differential equation: $$\dot{\xi} = [J(\xi) - R(\xi)] \nabla \mathcal{H}(\xi)$$ Where $J$ is a skew-symmetric matrix (representing energy-preserving interconnections) and $R$ is a positive semi-definite matrix (representing dissipation or friction).

  • Passivity and Convergence: Because the system is "passive" (it only loses or preserves energy, never gains it), the loss function is guaranteed to be non-increasing. The weights essentially "roll" down the loss landscape, losing kinetic energy due to the dissipation term $R$ until they stop at a local minimum.

The authors describe two training modes: Sequential (updating based on one data point at a time, similar to online learning) and Batch (using the entire dataset to define the energy landscape).

Datasets

The authors evaluated the PHNN on two primary tasks:

  1. Linear Boundary Classification: A synthetic dataset consisting of two bivariate Gaussian distributions (1,000 points each).
  2. Vector Field Approximation (Duffing Oscillator): A more complex task where a 3-layer neural network (354 parameters) was trained to approximate the nonlinear dynamics of a Duffing oscillator. Data was generated by sampling 400 points from a single continuous trajectory of the oscillator.

Key Insights and Ideas

  • Physics-Inspired Robustness: By using the PH framework, the optimizer inherits "passivity," a property from control theory that ensures stability. You don't just hope it converges; the physics of the system forces it to.
  • Escaping Saddle Points: In the Duffing oscillator experiment, the authors observed a "ripple" in the parameter velocities around the 20-second mark. This indicates the system passing through a saddle point. Unlike standard gradient descent, which might stall, the PHNN’s momentum-like dynamics allowed it to accelerate through the saddle point to find a better minimum.
  • Implicit Regularization: The formulation naturally includes terms that act like weight decay (Tikhonov regularization). By adjusting the "potential energy" of the weights, the system can be encouraged to find simpler, lower-norm solutions.

Key Results

  • Guaranteed Convergence: In both the linear and nonlinear tasks, the loss function ($\mathcal{J}^*$) showed a strictly monotonic decay over time.
  • Successful Approximation: The PHNN successfully learned the complex vector field of the Duffing oscillator, even in regions of the state space where it had no training data, demonstrating good generalization.
  • Computational Complexity: The authors note that while PHNNs require an extra state per parameter (the momentum), the space and time complexity remain linear ($O(p)$), making them theoretically comparable to standard gradient descent.

Limitations and Future Work

  • ODE Solver Overhead: Training requires numerical integration of ODEs. While theoretically efficient, the practical wall-clock time depends heavily on the choice of ODE solver (e.g., Scipy's odeint), which can be slower than simple discrete updates.
  • Hyperparameter Sensitivity: The performance depends on the choice of the damping matrix ($B$) and the inertia matrix ($M$). The paper leaves the optimal design of these "control inputs" as an open problem.
  • Scaling to Large Models: The experiments were performed on relatively small networks (hundreds of parameters). Testing this approach on massive architectures like ResNets or Transformers is necessary to prove its viability for modern deep learning.
  • Stochasticity: The current work focuses on deterministic dynamics. Extending this to a "Stochastic PHNN" to handle noisy mini-batches would be a logical next step.

Summary updated

BibTeX
@inproceedings{massaroli2019port,
  author = {Stefano Massaroli and Michael Poli and Federico Califano and Angela Faragasso and Jinkyoo Park and Atsushi Yamashita and Hajime Asama},
  title = {{Port-Hamiltonian Approach to Neural Network Training}},
  booktitle = {CDC},
  year = {2019},
  doi = {10.1109/cdc40024.2019.9030017},
}
Figure