Abstract
Predictive Coding (PC) offers a biologically plausible alternative to backpropagation by minimizing local prediction errors across network layers. However, the iterative inference phase required to update internal neuron activities often becomes a computational bottleneck. We introduce JPC, a lightweight JAX library that frames this inference process as an Ordinary Differential Equation (ODE) problem. By leveraging modern numerical solvers like Heun’s method, JPC significantly reduces wall-clock time in deep networks while maintaining competitive accuracy across standard benchmarks.
Introduction
Predictive Coding (PC) is gaining traction as a neuro-inspired learning framework. Unlike backpropagation, which relies on a global error signal, PC minimizes local "prediction errors" at every layer. While theoretically appealing, PC research has been constrained by the lack of high-performance software tools.
The primary bottleneck in PC is the inference phase. Before weights can be updated, the network must iteratively adjust its internal neuron activities to minimize an energy function. Most existing implementations rely on simple Euler integration—essentially standard gradient descent—which scales poorly as networks grow deeper. JPC addresses this by integrating the JAX ecosystem with modern numerical ODE solvers to streamline and accelerate PC training.
Methodology: Inference as Integration
JPC is a functional, modular library (under 1,000 lines of code) built on three core JAX pillars: Equinox for model definition, Diffrax for ODE integration, and Optax for weight optimization.
The key technical innovation in JPC is treating the inference dynamics ($\dot{z}_\ell = -\partial \mathcal{F}/\partial z_\ell$) as a continuous gradient flow. While traditional methods use 1st-order Euler integration, JPC defaults to Heun’s method, a 2nd-order explicit Runge-Kutta method. Although Heun’s method requires more computation per step, it converges in significantly fewer steps, leading to a net gain in wall-clock speed.
Experimental Setup
The authors evaluated JPC using standard image classification benchmarks, including MNIST, Fashion-MNIST, and CIFAR-10. To assess scaling, experiments were conducted across varying network depths, specifically 3, 5, and 10 hidden layers. This allowed for a direct comparison of how different ODE solvers handle increasing architectural complexity.
Key Results: Efficiency and Scaling
JPC demonstrates that framing the search for neuron equilibrium as an ODE problem allows researchers to tap into decades of numerical analysis. This shifts PC away from hand-tuned gradient descent steps toward robust, adaptive integration.
Runtime Efficiency
Heun’s method consistently outperformed Euler integration in wall-clock time across all datasets. The speedup provided by higher-order solvers becomes more dramatic as the network depth increases. For a 10-layer network ($H=10$), the reduction in training time is substantial, as shown in the runtime diagnostics.
Performance and Simplicity
Despite the faster inference, models trained with JPC achieved test accuracies comparable to traditional PC implementations. The library provides a simple "one-liner" API (make_pc_step) that manages the complex bi-level optimization while remaining fully compatible with JAX’s jit compilation for maximum performance.
Discussion and Future Directions
While JPC offers significant speedups, the authors note that results can still be influenced by optimizer-specific hyperparameters. Current benchmarking has focused on discriminative tasks, but the library's support for generative and hybrid models opens doors for broader applications.
A promising future direction is the integration of stochastic differential equation (SDE) solvers. Recent research suggests that adding noise to the inference process (Langevin dynamics) can significantly improve the performance of generative PC models, a feature JPC is well-positioned to support through its integration with Diffrax.
Summary updated