Fast Neural Kernel Embeddings for General Activations

Insu Han, Amir Zandieh, Jaehoon Lee, Roman Novak, Lechao Xiao, Amin Karbasi

Introduction

In the "infinite width limit," deep neural networks behave like Gaussian Processes. This theoretical breakthrough allows researchers to use two powerful mathematical objects—the Neural Network Gaussian Process (NNGP) kernel and the Neural Tangent Kernel (NTK)—to study how neural networks generalize and optimize.

Despite their theoretical importance, these kernel methods face two major hurdles in large-scale, practical settings:

  1. Computational Cost: Calculating these kernels for $n$ data points typically requires $O(n^2)$ time and memory. This quadratic complexity is prohibitively expensive for large, real-world datasets.
  2. Activation Rigidity: Most existing "fast" formulas and theoretical analyses only work for the ReLU activation function. While ReLU is popular, modern architectures increasingly rely on a variety of other functions (like GeLU in Transformers or Sinusoidal functions in NeRFs). Computing kernels for these "general" activations is mathematically difficult and often lacks closed-form solutions.

Overcoming Activation Rigidity

To address the limitation of activation rigidity, the authors compile and significantly expand the list of activation functions that admit exact dual activation expressions.

Table of activation functions and their NNGP/NTK references, highlighting the novel derivations introduced in this work.

As shown in the table above, this work provides novel NTK and NNGP references for a wide array of functions, including Hermite polynomials, Sinusoidal, GeLU, ELU, and Gabor activations. By open-sourcing their work within the Neural Tangents library, the authors make it possible for researchers to seamlessly experiment with new activations without deriving complex NTK mathematics from scratch.

Methodology: Fast and General Embeddings

To bridge the computational and mathematical gaps, the authors introduce a multi-pronged approach:

  • Hermite Expansion: The authors demonstrate that any smooth activation function can be expanded into a series of Hermite polynomials. This mathematical translation allows them to derive a "dual kernel" (the fundamental building block of NNGP/NTK) for virtually any activation function.
  • Automatic NTK Derivation: A highly practical contribution of this paper is a theorem showing that if the dual kernel for an activation is known, the dual kernel for its derivative can be automatically derived using a simple partial derivative. This eliminates tedious manual calculus.
  • Randomized Sketching: To solve the $O(n^2)$ complexity bottleneck, the authors employ PolySketch. This technique creates low-dimensional "embeddings" (sketches) of the data. Instead of computing a massive $n \times n$ matrix, the system processes a much smaller $m \times n$ matrix, effectively turning quadratic bottlenecks into near-linear operations.
  • Gauss-Hermite Quadrature: For activations where an exact formula remains elusive, the paper provides a numerical integration method to approximate the kernel both accurately and quickly.

Key Findings and Results

The proposed framework yields impressive empirical and theoretical results:

  • Massive Speedups: On the CIFAR-10 dataset, the approximate Convolutional NTK (CNTK) method achieved a staggering 106x speedup compared to exact computation for a 5-layer "Myrtle" network.
  • Improved Accuracy: By utilizing a "scaled normalized Gaussian" kernel—enabled by their general framework—the authors achieved 78.13% accuracy on CIFAR-10. This outperforms the standard ReLU-based CNTK (75.56%) within the same runtime constraints.
  • Efficiency over Sampling: The Hermite-based approximation consistently outperformed traditional Monte Carlo estimation, providing lower error in less "wall-clock" time across all tested activations (ReLU, Abs, Sin, GeLU, etc.).
  • Smoothness is a Feature: Surprisingly, smooth activations (like Gaussian or Sinusoidal) are actually easier to approximate with Hermite polynomials than non-smooth ones like ReLU. The approximation error for smooth functions drops much faster as more terms are added to the expansion.
  • Beyond the Unit Sphere: Many prior theoretical works required data to be normalized to a unit sphere. This framework relaxes that constraint, making it applicable to raw, real-world data in $\mathbb{R}^d$.

Limitations and Future Work

While this paper significantly advances the utility of neural kernels, some limitations remain. The most efficient subspace embedding results still rely on the dual kernel being "homogeneous." While many activations fit this criterion, it is not universal. Additionally, while the speedup is massive, computational complexity still scales with the number of layers ($L$), suggesting that future work might explore more aggressive compression for very deep architectures. Finally, extending these fast embeddings to the attention mechanisms found in Transformers remains an exciting area for further exploration.

Summary updated

BibTeX
@inproceedings{han2022fast,
  author = {Insu Han and Amir Zandieh and Jaehoon Lee and Roman Novak and Lechao Xiao and Amin Karbasi},
  title = {{Fast Neural Kernel Embeddings for General Activations}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=yLilJ1vZgMe},
}
Figure