SplineCam: Exact Visualization and Characterization of Deep Network Geometry and Decision Boundaries

Ahmed Imtiaz Humayun, Randall Balestriero, Guha Balakrishnan, Richard G. Baraniuk

Abstract

Deep Neural Networks (DNs) using piecewise linear activations like ReLU partition their input space into a complex arrangement of convex polytopes. While these "linear regions" are fundamental to understanding model expressivity and decision boundaries, their exponential growth with network depth has historically made exact computation impossible. We present SplineCam, a scalable, provably exact algorithm that leverages affine spline theory to enumerate these regions and visualize the exact geometry of deep networks. SplineCam enables researchers to peer into the "stained glass" mosaic of a model's input space, offering new insights into the structural differences between CNNs and MLPs, the impact of positional encoding, and the hierarchical nature of learning in implicit neural representations.

What Problem Does This Paper Address?

Despite their transformative success, Deep Networks (DNs) remain largely "black boxes." Most interpretability tools rely on approximations: saliency maps highlight important pixels, and boundary-finding tools sample points near the edge of a class. However, these methods fail to provide the exact geometry of the model's mapping, which is crucial for understanding robustness and generalization.

3D visualization of a Continuous Piece-Wise Linear (CPWL) function.

We know that networks using activations like ReLU are Continuous Piece-Wise Linear (CPWL). This means they divide the input space into a massive collection of convex polytopes (cells); inside each cell, the network behaves as a simple linear function. The challenge has been that the number of these cells grows exponentially with depth, making it computationally daunting to map them out exactly—until now.

Methods: The Spline View

The authors introduce SplineCam, a scalable enumeration algorithm that leverages the theory of affine splines. Instead of treating the network as a sequence of matrix multiplications, they represent it as a composition of operators where each layer's neurons act as "hyperplanes" that slice the input space.

  1. Exact Partitioning: Rather than sampling, SplineCam takes a 2D slice of the input space and iteratively computes the intersections of every neuron's boundary across all layers.
  2. Back-Projection: It uses a clever "back-projection" lemma to map hyperplanes from deep layers (e.g., layer 50) all the way back to the input space, accounting for how previous layers have already warped and sliced that space.
  3. Graph-Based Cycle Finding: It treats the intersections as a graph and uses a breadth-first search (BFS) heuristic to find the closed "cycles" that form the boundaries of each linear region.

Unlike previous attempts that were exponentially slow, SplineCam is vectorized and GPU-friendly, making it feasible for large architectures like VGG16.

Key Insights and Ideas

The "Stained Glass" Effect

Visualizing the partitions reveals a beautiful, mosaic-like structure. The density of these regions serves as a direct proxy for the "expressivity" or complexity of the learned function. In tasks like Implicit Neural Representations (INRs), such as the Stanford Bunny Signed Distance Field (SDF), SplineCam reveals how the network concentrates its geometric complexity.

SplineCam visualization of the Stanford Bunny SDF and its linear regions.

CNNs vs. MLPs

For the same number of parameters, Convolutional Neural Networks (CNNs) create significantly more linear regions than standard MLPs. This is because convolutions reuse weights to "cut" the input space multiple times in a structured way, leading to a much higher density of partitions and, consequently, higher expressivity.

The Role of Positional Encoding (PE)

In models like NeRF, positional encoding is often used to help ReLUs fit high-frequency data. SplineCam shows that PE effectively "wraps" the input space, causing neurons to repeat periodically and dramatically increasing the number of regions available to fit the signal.

Hierarchical Learning and Generalization

In SDFs, neurons from all depths—not just the final layer—align their boundaries near the target surface. This suggests a hierarchical coordination where the network "focuses" its geometric complexity exactly where the decision boundary needs to be. Furthermore, networks trained with Data Augmentation (DA) show a much higher density of regions at test time, suggesting that DA "prepares" the geometry of the network to handle a wider variety of inputs by creating a finer-grained partition.

Key Results

  • Efficiency: SplineCam can compute over 132,000 regions for a large MLP in just 134 seconds. For a massive model like VGG16 (138M parameters), it can find 1,000 regions in about 7 minutes.
  • Quantitative Complexity: On Fashion-MNIST, a CNN produced 28,222 regions compared to an MLP's 1,364 regions, despite the CNN having fewer parameters.
  • Exact Boundaries: The tool allows for "sampling from the boundary" with zero error, producing images that sit exactly on the knife-edge between two classes (e.g., an image that is 50.000% "cat" and 50.000% "dog" to the model).

Limitations and Future Work

While SplineCam is exact, it currently operates on 2D slices of the input space. While these slices are representative, they do not capture the full high-dimensional "volume" of the partitions. Additionally, the method is strictly for CPWL activations (ReLU, Leaky ReLU, Maxout). It cannot be directly applied to smooth activations like Sigmoid or GeLU, though the latter can be approximated with piecewise linear segments. Finally, the algorithm requires double-precision (float64) to avoid "vanishing" regions due to rounding errors in very deep networks.

Project Website: bit.ly/splinecam

Summary updated

BibTeX
@inproceedings{humayun2023splinecam,
  author = {Ahmed Imtiaz Humayun and Randall Balestriero and Guha Balakrishnan and Richard G. Baraniuk},
  title = {{SplineCam: Exact Visualization and Characterization of Deep Network Geometry and Decision Boundaries}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
}
Figure