Mean-Field Limits for Two-Layer Neural Networks Trained with Consensus-Based Optimization

William De Deyn, Michaël Herty, Giovanni Samaey

TL;DR

This paper explores Consensus-Based Optimization (CBO)—a gradient-free, particle-based global optimization method—as a robust alternative for training two-layer neural networks. The authors introduce a high-performance hybrid CBO-Adam algorithm and a memory-efficient multi-task variant, while providing a rigorous theoretical foundation by deriving mean-field limits within an optimal transport framework.

What Problem Does This Paper Address?

Most neural networks are trained using gradient-based methods like SGD or Adam. While powerful, these methods are prone to getting stuck in local minima and can suffer from vanishing or exploding gradients.

Consensus-Based Optimization (CBO) offers a different path: it is a "gradient-free" global search method where a population of "particles" (candidate weight sets) explores the loss landscape. These particles are pulled toward a "consensus point"— a weighted average of the population where the best-performing particles have the most influence. However, applying CBO to neural networks is challenging because the parameter space is high-dimensional. Furthermore, there has been a lack of theoretical understanding regarding how CBO behaves as neural networks become infinitely wide (the "mean-field" regime).

Methods

The authors propose and analyze several advancements to the CBO framework:

  • Hybrid CBO-Adam: To combine the global exploration of CBO with the local refinement speed of Adam, the authors propose a hybrid update rule. A parameter $\gamma$ controls the influence of each method, allowing the optimizer to benefit from both worlds.
  • Multi-Task CBO: In multi-task learning, the authors suggest "recycling" the same ensemble of particles across related tasks. Instead of sampling new particles for every task, the same population is used to find different consensus points for different objectives, significantly reducing memory overhead.
  • Optimal Transport (OT) Formulation: To handle the "infinite width" limit (where the number of hidden neurons $M \to \infty$), the authors stop treating neural networks as points in a high-dimensional vector space. Instead, they represent them as probability measures. They reformulate CBO dynamics using Wasserstein barycenters, which allows them to define the optimization process on the space of measures.
  • Mean-Field Analysis: The paper derives the limits for both an infinite number of neurons ($M \to \infty$) and an infinite number of optimization particles ($N \to \infty$).

Datasets

The authors evaluated their methods on four benchmarks:

  1. Sine Approximation: A 1D regression task ($x \to \sin(2\pi x)$) used to compare basic CBO stability against Adam.
  2. MNIST: The classic handwritten digit classification dataset (using a subset of 10,000 images) to test the Hybrid method in a higher-dimensional classification setting.
  3. Shifted Sine Functions: A synthetic multi-task benchmark consisting of 100 related regression tasks to demonstrate the efficiency of particle recycling.
  4. Square Approximation: A regression task ($x \to x^2$) used specifically to validate the Optimal Transport formulation as the network width $M$ increases.

Key Insights and Ideas

  • Stability over Speed: On the MNIST task, Adam initially converged faster but eventually became unstable due to exploding gradients. The Hybrid CBO-Adam method remained stable and achieved a lower final risk, suggesting that CBO acts as a "stabilizer" in difficult optimization landscapes.
  • The Power of Recycling: The Multi-Task CBO experiment showed that a single set of particles can effectively solve 100 different problems simultaneously. This is an "aha moment" for efficiency: if tasks are related, their global minimizers likely live in the same region of the parameter space.
  • Mathematical Convergence: By moving to the "Wasserstein-over-Wasserstein" space (the law of the measures), the authors proved that the variance of the particle population decreases monotonically. This provides a rigorous guarantee that the particles will eventually reach a consensus.
  • Width Improves Optimization: In the OT formulation, the authors observed that wider networks ($M=200$ vs $M=10$) converged to lower empirical risks, confirming that the theoretical benefits of the Barron space (the function space for 2-layer networks) translate into better optimization performance.

Key Results

  • Hybrid Performance: On MNIST, the Hybrid method converged significantly faster than pure CBO and avoided the late-stage instability seen in Adam.
  • Multi-Task Efficiency: The Multi-Task CBO successfully minimized 100 different MSE risks using only 200 particles in total, demonstrating massive memory savings compared to running 100 independent optimizers.
  • Theoretical Bound: The authors proved that in the mean-field limit, the population variance $V(\rho^{k+1})$ is bounded by $(1 - \Delta t)^2 V(\rho^k)$, ensuring a steady march toward consensus.

Limitations and Future Work

  • Computational Overhead: CBO requires a forward pass through the neural network for every particle at every iteration. This makes it computationally more expensive per step than standard gradient-based methods.
  • Barycenter Complexity: While the Optimal Transport formulation is theoretically elegant, computing Wasserstein barycenters in every iteration is computationally taxing, which currently limits its practical use for very large-scale networks.
  • Deterministic OT: The current OT formulation is deterministic and lacks a natural "Brownian motion" (diffusion) term. The authors had to add artificial noise to maintain exploration, and they suggest that developing a more natural stochastic OT formulation is a key area for future research.

Summary updated

Abstract

We study Consensus-Based Optimization (CBO) for two-layer neural network training. We compare the performance of CBO against Adam on two test cases and demonstrate how a hybrid approach, combining CBO with Adam, provides faster convergence than CBO. Additionally, in the context of multi-task learning, we recast CBO into a formulation that offers less memory overhead. The CBO method allows for a mean-field limit formulation, which we couple with the mean-field limit of the neural network. To this end, we first reformulate CBO within the optimal transport framework. In the limit of infinitely many particles, we define the corresponding dynamics on the Wasserstein-over-Wasserstein space and show that the variance decreases monotonically.
BibTeX
@misc{deyn2025mean,
  author = {William De Deyn and Michaël Herty and Giovanni Samaey},
  title = {{Mean-Field Limits for Two-Layer Neural Networks Trained with Consensus-Based Optimization}},
  year = {2025},
  eprint = {2511.21466},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.21466},
}
Figure