Revealing Pathway Interactions in Network Computations with Complete Path Contribution
Authors: Shenghua Liu, Youssef Faragalla, Surya Ganguli, Stephen A. Baccus
Organizations: Department of Physics, Stanford University · Neurosciences Interdepartmental Program, Stanford University · Department of Applied Physics, Stanford University · Department of Neurobiology, Stanford University
Networks pass signals through many layers of interconnected units, so explaining what they compute means tracing how information travels from input to output and how pathways interact. Most existing approaches analyze only pairwise interactions between components such as units, layers or attention heads. Even when these measurements are combined post hoc into a circuit, they do not capture higher-order interactions along full causal chains (paths) from input to output, and so cannot address how exponentially many paths interact to construct network computation. This leaves a large set of mechanistic questions unanswerable, for example whether inhibitory pathways veto excitatory ones, and how the two combine to yield network decisions. To address this gap, we introduce Complete Path Contribution, a method to decompose the network output into mathematically complete contributions of individual paths to study path-level interactions directly and at scale. Partial summation then induces definitions of contributions for any circuit at any granularity level, with completeness guaranteed at every level. We further present an efficient algorithm that identifies the k strongest paths without examining all of them, with runtime empirically linear in k rather than exponential in depth. By applying Path Contribution to benchmark image classification networks, we quantify excitatory-inhibitory interactions and show how they collectively construct network decisions at a level of detail previously unmeasurable. Furthermore, in an interpretable model of the mouse retina, it reveals how dynamic receptive fields emerge from excitatory-inhibitory interaction motifs among pathways between different cell types in response to time-varying natural stimuli. Overall, Path Contribution reveals how a network's causal pathways interact at scale to transform input to output.
Figures & tables
Figure 1: (A) The contribution of a path is the chained gradient along its edges integrated over a straight line path in input space. (B) A neuron’s contribution is a composition of its receptive and projective fields. The RF and PF both involve many parallel pathways, and they compose individually into full paths from input to output.
Figure 2: A toy model with two inputs computes d=a+b−a×b . Each heatmap shows the relevant quantity as a function of inputs. Contributions are computed with a zero baseline, so Δd=d is the output, shown at the top. The middle row shows the activation and contribution of the three neurons. The bottom row shows the contribution of each of the four paths. Due to hierarchical completeness, Cad+Cacd=Ca , Cacd+Cbcd=Cc , Cbcd+Cbd=Cb , and Ca+Cb=Δd . Observe cancellations indicated by the green boxes and green circles, which are not discoverable at the neuron level.
Figure 3: Analysis of pathway interactions in a “silent” neuron’s PF in an MNIST-trained MLP. A silent neuron is one that is active but contributes little to the output. (A) The model: A 3-layer MLP with 128 neurons per layer trained on MNIST. (B) The silent neuron selected by a set of criteria: activity—the neuron is active on at least 30% of the validation set, importance—its mean absolute contribution over the validation set to the correct logit is in the top quartile, and silence—a small correlation between its activation and contribution. (C) The activation and contribution of the selected neuron h1[13] on each of the 100 (input image class, output logit) scenario, over 20 random images of each class. Contribution is computed with a zero baseline at 64 integration steps. h1[13] has an approximately linear PF: one dominant pattern over the logits, scaled by the activation. However, a nonlinear feature is indicated by the scenario in the red box, where on images of 3s it barely contributes at all to logit 3 despite being consistently inhibitory for other images. (D) A small fraction of paths in the neuron’s PF reconstructs the contribution pattern over scenarios with high accuracy. (E) Total E and I effects in h1[13]’s PF at the neuron (which includes h2 and h3 neurons) and path levels, in five settings. Neuron contributions are mostly decided by the output logit, and are mostly all E or all I. Paths, however, exhibit a high level of cancellation resulting in the same residual sum. On images of 3 taken to the 3 logit (3s@3), E and I effects almost cancel perfectly at both the neuron and path levels. (F) The full path contribution matrix conditioned on h1[13], with paths in a row summing to an h2 neuron’s contribution and columns to h3 neurons. Sorted by neuron contribution into quartiles, and within each quartile sorted by the variance. Many h2 and h3 neurons have no net effect, yet path contribution reveals that it is due to large cancellation between paths in some cases (green box) and paths being individually weak in others (gray). An enlarged version of this plot is in Figure 24 . (G) A smaller fraction of paths is needed to reconstruct the contribution properties of h1[13] compared to downstream neurons, suggesting more sparsity at the path level.
Figure 4: Path contributions to activity and receptive fields of a retinal ganglion cell. (A) Schematic diagram of a 3-layer CNN fit to mouse retinal ganglion cell firing rate responses. A 30 -frame (100 x 100) window of a natural movie drives two layers of 16 channels each, read out through a fully connected layer to the rates of all 36 simultaneously recorded cells. Paths are computed for each hidden unit and summed over one pair (c0,c1) of channels, one path of the 16×16=256 through the network. The path shown in red, 12→13 , is the strongest by mean contribution and the first trace in panel F. (B) Predicted firing rate of one cell, r=0.57 against the recorded rate. The dashed line marks the firing peak used in panels G and H. (C, D) Contributions of the 16 conv0 and conv1 units at each time point, obtained by summing the path matrix over the other layer’s index. These values are channel-wise contributions for a given layer ( Melander et al., 2026 ) . (E) All 256 path contributions Pt[c0,c1] grouped by conv0 channel; panels C and D are its two marginals. Arrows mark the paths traced in panel F. (F) The three strongest excitatory and inhibitory paths, ranked by mean contribution over the displayed interval. (G) The path matrix at the marked time point, flanked by the two marginals of panels C and D; each marginal is labelled with the index it sums over. Circles mark the paths whose filters are added in panel H. (H) The instantaneous receptive field (IRF) ( Maheswaranathan et al., 2023 ) assembled from those paths. Colored borders match paths in panel G. Three paths of 256 sum to r = 0.95 with the IRF.
Figure 5: Circuits formed by paths acting in concert. Principal components of the 256×T matrix of path contributions, taken over the whole clip. (A) Each circuit drawn over the channel graph, along with the percentage of variance it accounts for. A circuit’s paths are those contributing above 5% of its maximum ( 15 , 45 , 59 and 70 paths, respectively). One line per path, its width the magnitude of that path’s average contribution in the circuit and its color the sign. Line width is the path contribution, not the layer-to-layer weight. (B) Path contributions of the same circuits shown as a 16×16 matrix. (C) The average receptive field that the circuit implements. (D) Contribution of each circuit over time. Shown at each time point are summed contributions for the paths in panel A labelled in red (net positive) or blue (net negative), and the total contribution (black) along with the firing rate (gray). All contributions sum to the firing rate minus the response to the baseline, which is 0.05 Hz for this cell. (E) Receptive field contributions for circuit components that are either excitatory or inhibitory, on average, summed over a long stretch of data. Each component has positive and negative values because local increases and decreases in intensity can drive either excitation or inhibition.
Appendix figures & tables21 assets
Supplementary material from the paper’s appendix.
Appendix
Subnetwork H
Masks
C(H)
Input pixel i0
m0=ei0
Integrated Gradients
Neuron (l,j)
ml=ej
Neuron conductance
Component S⊆Vl
ml=1S
Component contribution, e.g., conv channel
Edge (l,j)→(l+1,k)
Ml,l+1=ekej⊤
Edge (weight) contribution
Path (i0,…,iL)
ml=eil for every l
Path contribution
Appendix
Table 1: Special cases of Definition 2 . Layers not listed keep their full sets of neurons and edges.
Figure 6: Interactions among h1[13]’s downstream pathways under four baselines, in the setting of Figure 3 (3s@3, mean over all 1,012 validation images of 3, 64 integration steps). Black is the baseline of the main text; gray sets every pixel to 1/2 and white to 1; mean is the mean of all MNIST validation images. (A) Total E and I through h2 neurons and through h2-h3 paths, with the net contribution as a dotted line, as in Figure 3 E. E and I are similar under all four baselines, while the net contribution differs. (B) The class-mean path contribution matrix with its conditional marginals, as in Figure 3 F. Rows and columns keep the order of the black baseline, and the four matrices and marginals share the same scale respectively.
Figure 7: Path rankings and signs under three baselines, compared with the black baseline, in the setting of Figure 6 . Each column is one baseline. An image is left out of a column if its path contribution matrix is identically zero under that baseline (since ranking and sign flip become meaningless), which happens when h1[13] is inactive at every integration step; this leaves 541 (gray), 526 (white) and 560 (mean) of the 1,012 images. (A) Top- k overlap with the black baseline, as a distribution over images, for k=10 , 100 and 1,000 of the 16,384 paths. Boxes show quartiles and whiskers extend to 1.5 times the interquartile range; outliers are not drawn. Red dotted lines show the overlap of the class-mean paths. (B) Histogram over images of the share of the black baseline’s top 1,000 paths whose contribution has the opposite sign under the column’s baseline. The red dotted line marks the share for the class-mean matrices, which is zero. (C) The same share against the activation of h1[13] at the image. Vertical lines mark the activation of h1[13] at the column’s baseline (dashed) and at the black baseline (dotted). Paths change sign only on images whose activation lies between the two.
Figure 8: Convergence in the number of integration steps, in the setting of Figure 3 (black baseline, all 1,012 validation images of 3). Boxes show quartiles and whiskers extend to 1.5 times the interquartile range; outliers are not drawn. (A) Blue: the absolute change of each path’s contribution from its value at 512 steps, as a distribution over the 16,384 paths, at 8 to 256 steps. Gray: the absolute contribution at 512 steps, for reference. Left: the class-mean contributions. Middle and right: the two images with the largest and the smallest ∣c∣ among the 561 images on which h1[13] is active, where c is the contribution of h1[13] on the image at 512 steps. (B) Blue: the absolute completeness error—difference between the sum of all paths and the output change—, as a distribution over images, at 8 to 512 steps. Gray: the absolute output difference. Circles show the class mean. (C) Overlap between the top- k paths of an image at each step count and its top- k at 512 steps, as a distribution over images. The axis is logarithmic in one minus the overlap. Images whose path contributions are all exactly zero at a step count (179 at 8 steps and 38 at 16) are left out at that step count.
Figure 9: Head-head interaction motifs in ViT-B trained on ImageNet. (A) Mean contributions of paths that pass through specified attention heads at block 3 and block 9, taken over the 50 validation images of the “pill bottle” class, using an ImageNet mean baseline and 512 integration steps. Paths that go through the residual stream in one layer and a head in the other dominate contribution. However, head-head contributions still reveal E-I interaction not visible at a single layer (rows and columns are sums over E and I paths contained in them). (B) PCA coefficients on the head-head contributions over 50 images sorted by PC1. Both PC2 and PC3’s coefficients vary across inputs, and sometimes flip sign. (C) The mean offset and top three PCs of head-head contributions.
Figure 10: Head-head interactions in ViT-B across four classes, at blocks 1 and 5. Each column is one class, with its 50 validation images taken to the logit of the class. (A) Total E and I of the class-mean contributions in the four parts of the paths (types of head-stream interactions): ww, paths that bypass the heads of both blocks through the residual stream (the wire); hw, paths through a head of block 1 and the wire at block 5; wh, paths through the wire at block 1 and a head of block 5; hh, paths through a head of each block. The dotted line is the net contribution of the part. (B) Coefficients of the first three PCs of the head-head contributions over the 50 images, sorted by the PC1 coefficient. (C) The mean head-head contribution of each pair of heads. (D) The first PC of the head-head contributions. Each row shares one scale.
Figure 11: Head-head interactions in ViT-B across three pairs of blocks, for the 50 validation images of the pill bottle class. Each column is one pair of blocks; panels are as in Figure 10 , with the first letter of a part naming the earlier block. The four parts divide the output differently in each pair, the first PC and coefficient scales differ between pairs.
Figure 12: Scaling of the top- k algorithm on MNIST-trained MLPs, on an M3 Pro MacBook Pro with 36 GB of memory. The base run has 3 hidden layers of 128 neurons each, 32 integration steps, and the mean over 16 images. (A) Scaling over each of the four dimensions, with the others held at the base. (B) Scaling over k , the number of top paths to return, for the base run and each dimension maxed out.
Figure 13: (A) Coverage of Δy as a function of the fraction of a population included: top paths among all paths, top neurons among all neurons in a layer, and top edges among all edges in a layer. About 10 times fewer paths are needed by fraction to cover half of the output compared to edges, and another 10 times fewer than neurons. (B) The number of top paths found using a sequential beam search by most important neurons or edges. A beam search over edges needs to enumerate about 100 times more paths than requested, and neurons 100 times even more.
Figure 14: Cancellation between pathways across neurons, input-output scenarios and random seeds, in the setting of Figure 3 . A scenario c s@ k is the validation images of class c with contributions taken to logit k . For each h1 neuron in each of the 100 scenarios, the class-mean contribution is divided into the neuron’s 128 edges to h2 neurons, or into its 16,384 paths through h2 and h3. E and I are the sums of the positive and negative contributions; the gross contribution is E−I and the net contribution is E+I . (A) Two-dimensional histograms of the gross contribution against the absolute net contribution over all neuron-scenario pairs, for the network of Figure 3 . Diagonal lines mark a ratio of gross to absolute net contribution of 1, 10 and 100. Red circles mark h1[13] in three scenarios of Figure 3 E. (B) Distribution over neuron-scenario pairs of the ratio of gross to absolute net contribution, for networks trained from three random seeds.
Path
Contribution
Remove one
Keep one
Shapley value
a→d
a
a
a
a
a→c→d
−ab/2
−ab
0
−ab/2
b→c→d
−ab/2
−ab
0
−ab/2
b→d
b
b
b
b
Sum
a+b−ab
a+b−2ab
a+b
a+b−ab
Appendix
Table 2: Path contribution and patching effects for the four paths of the toy model d=a+b−a×b , with a zero baseline. Remove one is the difference between the full model and just that path patched, and keep one is the difference between just that path and the empty model.
Figure 15: Path contribution against path patching effect, for the paths of h1[13] in the network of Figure 3 , with the black baseline as the counterfactual input. The patching effect is the output keeping the paths in question minus the output with the paths patched, averaged over images in the scenario. (A) The 100 paths with the largest absolute class-mean contribution in 3s@3, ordered by contribution. Gray boxes show the distribution of the patching effect of each path over 3,001 contexts: each of the other 127 neurons of h1 is set to its baseline value with probability 0.1, 0.25 or 0.5 (1,000 contexts each), plus the context with no other neuron patched, which gives the remove-one effect (red). Boxes are quartiles and whiskers extend to 1.5 times the interquartile range; outliers are not drawn. Blue: the path contribution. (B) Each point is one of the 100 input-output scenarios. Left: the effect of patching all paths with a positive class-mean contribution, against the total E. Middle: minus the effect of patching all paths with a negative contribution, against minus the total I. Right: the effect of patching all 16,384 paths, against the net contribution. The gray line is the diagonal.
Figure 16: Fit quality for all 36 cells on the held-out repeat block. (A) Correlation between the predicted rate and the recorded rate, for a single trial and for the average over ten repeats; dashed lines are the medians. (B) Correlation of each cell with the ten-repeat average, with the cell’s noise ceiling, the square root of the split-half reliability of the average. (C) Predicted and recorded rate of the best-predicted cell.
Figure 17: The IRF from integrated path contribution matches the gradient IRF. (A) Cosine similarity between the two fields for all 36 cells at one frame. (B) The same at each cell’s frame of peak firing. (C) Both fields of the best-predicted cell at its frame of peak firing, at two lags before the response. (D) Time course of both fields, each projected on its own spatial pattern at the strongest lag.
Figure 18: Low-dimensional circuits and E–I cancellation in recorded ganglion cells. (A) Variance of the path contributions carried by the first PC, the first two and the first four. (B) E–I cancellation factor, ∑t(Et−It)/∑t∣Et+It∣ , the gross drive per unit of net output; 1 means no cancellation. (C) Share of the gross drive that is inhibitory. (D) Absolute cosine similarity between the first-PC loadings of pairs of cells, for ON–ON, OFF–OFF and ON–OFF pairs.
Figure 19: Path motifs are shared within, not across, cell polarity, for the 35 cells whose white-noise and natural-scene receptive fields agree in polarity. (A) Absolute cosine similarity between the first-PC loadings of every pair of cells, ON cells first. (B) Mean first-PC loading of the ON cells over the 16×16 paths. (C) The same for the OFF cells.
Figure 20: Mean-image baseline against a uniform gray baseline. (A) Gradient IRF and integrated-gradients IRF under each baseline, for the best-predicted cell at its frame of peak firing, on one color scale. (B) Time course of the three fields. (C) Cosine similarity between the fields over all 36 cells. (D–G) Per-cell first-PC variance, E–I cancellation factor, inhibitory share and fraction of paths taking both signs under the two baselines; points on the diagonal are unchanged. (H) Absolute cosine similarity between each cell’s first-PC loadings under the two baselines.
Figure 21: Integration steps, for all 36 cells on every sixth window of the held-out block; lines are medians and shading the interquartile range. (A) Relative completeness error against the number of trapezoid steps. (B) Difference from the 128 -step result of the contributions at each frame, the first-PC loadings and the cancellation factor; the dashed line marks single-precision accuracy. Dotted lines mark the 32 steps used throughout.
Figure 22: Two models trained on the same cells and data from different random seeds, for the cell and stimulus of the main text. (A) Recorded rate and the rate predicted by each model; the recorded trace is clipped. (B) Each model’s IRF and first-circuit IRF at the frame of the main text. (C) Summary statistics of the path decomposition. (D) Mean absolute contribution of each path in the original model. (E) The same in the second model, with its channels reordered to their matched counterparts in the original. (F) Cumulative contribution of the paths ranked by size, and variance of the leading PCs. (G) First-layer contributions over time, matched channels in the same order. (H) Summed excitatory (upward) and inhibitory (downward) drive. (I) Activation of the first circuit over time. (J) Linear centered kernel alignment between the two models’ path contributions, against a time-shifted control.
Figure 23: The same network over training, for all 36 cells on the held-out block; lines are medians over cells, shading the interquartile range. (A) Correlation with the recorded response, on the held-out block and on the validation block during training. (B) Cosine similarity to the final model of the clip-average and peak-frame IRFs, and of the clip-average IRF to the white-noise STA. (C) Similarity of the paths to the final model: the linear CKA over time, ∣cos∣ of the first-PC loadings, and top-10 path overlap. (D) Similarity to the final model against fit (% of final median correlation); numbers are epochs. (E) First-PC variance and cancellation factor. (F) Correlation across cells with the final values. (G) IRF and path map of the best-predicted cell, with its correlation and each map’s cosine similarity to the final model.
Understanding how neural networks transform inputs into outputs is crucial for interpreting and manipulating their behavior. Most existing approaches analyze internal representations by identifying hidden-layer activation patterns correlated with human-interpretable concepts. Here we take a direct approach to examine how hidden neurons act to drive network outputs. We introduce CODEC (Contribution Decomposition), a method that uses sparse autoencoders to decompose network behavior into sparse motifs of hidden-neuron contributions, revealing causal processes that cannot be determined by analyzing activations alone. Applying CODEC to benchmark image-classification networks, we find that contributions grow in sparsity and dimensionality across layers and, unexpectedly, that they progressively decorrelate positive and negative effects on network outputs. We further show that decomposing contributions into sparse modes enables greater control and interpretation of intermediate layers, supporting both causal manipulations of network output and human-interpretable visualizations of distinct image components that combine to drive that output. Finally, by analyzing state-of-the-art models of neural activity in the vertebrate retina, we demonstrate that CODEC uncovers combinatorial actions of model interneurons and identifies the sources of dynamic receptive fields. Overall, CODEC provides a rich and interpretable framework for understanding how nonlinear computations evolve across hierarchical layers, establishing contribution modes as an informative unit of analysis for mechanistic insights into artificial neural networks.
Joshua Brendan Melander, Zaki Alaoui, Shenghua Liu +2
Department of Neurobiology, Stanford University · Department of Physics, Stanford University · Department of Applied Physics, Stanford University
Feature attribution methods explain predictions by assigning importance scores to input features. Path-based methods such as Integrated Gradients are especially appealing because they satisfy completeness: attributions sum to the change in model output between a reference state and the input. Yet most path methods define this trajectory in input space, explaining a model through pointwise perturbed inputs along a chosen path. An input-space path integrates the model's raw response at each point it passes through, with no control over the resolution at which a feature is queried; the early, baseline-adjacent part of the trajectory contributes to the explanation on equal footing with the input itself. Here, we lift path attribution from input space to a space of structured probe distributions around the example of interest, and call our method Reveal-IG. Rather than traversing raw input values, Reveal-IG progressively reveals information about the input and attributes changes in the model's expected output along this distributional path. The result is a path-attribution framework that retains completeness with respect to the expected model response, and naturally accommodates multiscale image probes and feature-wise uncertainty in tabular data. Synthetic diagnostics show that Reveal-IG avoids path artifacts that affect input-space methods, and across ImageNet classification and tabular regression it produces stable, signed attributions -- leading on metrics that use attribution sign while remaining competitive on the rest.
Residual networks execute every block for every input, yet their functional contributions need not be input independent. We formulate a trained ResNet as a set function over binary residual-branch masks and apply Möbius inversion to decompose its output exactly into individual residual corrections and higher-order interactions. For smooth residual stacks, we show that each fixed k-way interaction scales as O(λk) under residual scaling. Exhaustive analysis of ImageNet-pretrained ResNet-18 and ResNet-34 reveals that interaction mass peaks at orders five and ten, respectively, rather than at low orders. Reducing the residual scale shifts both spectra toward lower orders, but also changes model predictions. The interaction coefficients are concentrated in magnitude but not hard sparse, and prediction-preserving sparsity weakens with depth. Crucially, the dominant interactions vary across inputs and predicted classes around a shared global core, while their overall complexity changes little with sample difficulty. These results show that dense ResNets implement an implicit form of soft routing: every block is executed, but different inputs rely on different residual interaction experts. Routing can therefore emerge at the level of functional contribution without an explicit router or sparse execution.
Liang Yan, Siying Chen, Kaijie Chen +3
Fudan University · University of Washington · Tongji University +2