Papers
Topics
Authors
Recent
Search
2000 character limit reached

Shapley Transform in Neural Networks

Updated 23 March 2026
  • Shapley Transform is a formal mechanism that embeds exact Shapley attributions as intrinsic, differentiable representations within neural network architectures.
  • It enables layerwise computation of feature contributions enabling efficient test-time attribution, explanation regularization, and dynamic pruning.
  • Shallow and Deep ShapNets leverage classical SHAP axioms to ensure local accuracy, missingness, and consistency while avoiding post-hoc computational overhead.

The Shapley transform is a formal mechanism for embedding exact Shapley attributions as intrinsic, differentiable representations within neural network architectures. It provides a principled framework to compute and utilize Shapley values layerwise, enabling explanation regularization, efficient test-time attribution, and dynamic pruning. Operationalized as Shapley modules and composed into Shallow and Deep ShapNets, the Shapley transform leverages both classical SHAP axioms and modern deep learning constructs, ensuring local accuracy, missingness, and scalability while avoiding the intractable overhead of post-hoc SHAP computation (Wang et al., 2021).

1. Mathematical Definition of the Shapley Transform

Let xRD×Cx\in\mathbb R^{D\times C} be an input tensor, with DD explainable dimensions and CC channel dimensions. For a given vector-valued function f:RD×CRCf:\mathbb R^{D\times C}\to\mathbb R^{C'}, with component functions fj(x)f_j(x), the Shapley transform Ω(x,f)\Omega(x,f) is defined as

Ω(x,f):RD×C×FRD×Cwith[Ω(x,f)]i,j=ϕi(x,fj)\Omega(x,f):\mathbb R^{D\times C}\times\mathcal F \to \mathbb R^{D\times C'} \quad\text{with}\quad [\Omega(x,f)]_{i,j} = \phi_i(x, f_j)

where ϕi(x,fj)\phi_i(x, f_j) is the classical Shapley value of the iith feature for the scalar function fjf_j. The resulting tensor Z=Ω(x,f)Z=\Omega(x,f) is referred to as the Shapley representation of xx under ff.

Local accuracy, missingness, and consistency—SHAP axioms established by Lundberg and Lee—are preserved in this construction. Specifically:

  • Local Accuracy: i=1Dϕi(x,f)=f(x)\sum_{i=1}^D \phi_i(x, f) = f(x) for scalar ff,
  • Missingness: If feature ii is absent (set to reference rir_i), then ϕi(x,f)=0\phi_i(x, f) = 0,
  • Consistency: If the marginal contribution of a feature does not decrease for all subsets, the corresponding Shapley value cannot decrease.

A foundational lemma establishes the linearity of the Shapley transform: For ARC×CA\in\mathbb R^{C''\times C'}, AZT=(Ω(x,f~))TA\,Z^T = (\Omega(x,\,\tilde f))^T with f~(x)=Af(x)\tilde f(x)=A\,f(x). Thus, linear mixing of Shapley channels yields valid Shapley representations for composed functions.

2. Shapley Modules: Neural Implementation of the Transform

A Shapley module is a neural network block realizing the Shapley transform for a scalar target function fjf_j of small active set A(fj)\mathcal A(f_j), i.e., A(fj)kD|\mathcal A(f_j)| \leq k \ll D. The outputs are

[Fj(x)]i={ϕi(x,fj)if iA(fj) 0otherwise[F_j(x)]_i = \begin{cases} \phi_i(x, f_j) & \text{if } i\in\mathcal A(f_j) \ 0 & \text{otherwise} \end{cases}

using a reference tensor rr. By restricting each fjf_j to few inputs, the O(2k)O(2^k) complexity for computing exact Shapley values becomes practical for k2k\approx 2–$4$. This enables differentiable, tractable attribution propagation as an intrinsic component of the model, in contrast to expensive post-hoc SHAP estimators.

3. Shallow ShapNets: Exact Attributions in a Forward Pass

A Shallow ShapNet is constructed by composing a bank of Shapley modules (one per output channel) followed by a sum over the explainable dimensions: Shallow(x)=i=1D[Ω(x,f)]i,RC\text{Shallow}(x) = \sum_{i=1}^D [\Omega(x, f)]_{i, \bullet} \in \mathbb R^{C'} with [Ω(x,f)]i,[\Omega(x, f)]_{i, \bullet} representing the Shapley values for each output. In this setting:

  • The output prediction equals f(x)f(x), and the internal representation matches the exact Shapley attributions.
  • All SHAP properties (local accuracy, missingness, consistency) are satisfied identically.
  • Expressive coverage of all DD features is achieved by aggregating pairs or small subsets in early modules, then linearly mixing, preserving expressivity by the linearity lemma.

4. Deep ShapNets: Layerwise Attribution and Dynamic Pruning

A Deep ShapNet stacks LL Shapley transforms: x(0)=x,x()=Ω()(x(1),f())RD×Cx^{(0)} = x, \quad x^{(\ell)} = \Omega^{(\ell)}(x^{(\ell-1)}, f^{(\ell)}) \in \mathbb R^{D\times C_\ell} with final output

H(x)=i=1D[x(L)]i,RCL\mathcal H(x) = \sum_{i=1}^D [x^{(L)}]_{i, \bullet} \in \mathbb R^{C_L}

Each layer consists of parallel Shapley modules (with small active sets) and optional learned linear mixing. A canonical “butterfly” (FFT-style) schedule organizes disjoint pairs per layer, ensuring that all pairwise feature interactions are eventually captured for L=log2DL = \log_2 D layers.

Key properties include:

  • Local accuracy: Achieved in the final prediction via telescoping of Shapley sums.
  • Missingness: If any feature’s attribution becomes zero at a layer, it is guaranteed to remain zero in all subsequent layers (Corollary 4.1), facilitating input-adaptive, dynamic pruning at inference.

5. Complexity, Efficiency, and Training Regularization

Computational Complexity and Efficiency

  • Per-module cost: O(2k)O(2^k) forward passes for Shapley value computation on the active set.
  • End-to-end model: A single forward pass through all Shapley modules yields both prediction and all internal explanations, matching the runtime of conventional DNNs of similar depth and width.
  • Test-time dynamic pruning: Features for which attributions become zero at any layer can be pruned in all downstream computations. This input-adaptive pruning reduces computation substantially for sparse or irrelevant features (Corollary 4.1).

Regularization via Shapley Representations

Since each intermediate tensor x()x^{(\ell)} is itself a Shapley attribution, regularization can be directly imposed on the intrinsic attributions. For example: λ1ixi,(L)1,λmaxixi,(L)\lambda_1 \sum_i \lVert x^{(L)}_{i, \bullet} \rVert_1, \qquad \lambda_\infty \max_i \lVert x^{(L)}_{i, \bullet} \rVert_\infty Such regularizers enforce sparsity or smoothness in the layerwise Shapley values, directly shaping attribution characteristics during training, rather than relying on smoothing post-hoc saliency maps.

6. Implications and Distinction from Post-hoc SHAP Approaches

The Shapley transform framework makes per-feature attributions intrinsic to the model, rather than an external analysis step. Unlike post-hoc SHAP methods (e.g., DeepSHAP, KernelSHAP) which require expensive sampling or backward passes, Shallow and Deep ShapNets compute attributions concurrently with predictions. This design provides:

  • Instantaneous computation of additive (Shallow case) or approximate (Deep case) SHAP attributions for arbitrary inputs,
  • Full support for attribution-based regularization in gradient-based optimization,
  • Input-specific dynamic computational savings via layerwise pruning,
  • Consistent satisfaction of SHAP properties (local accuracy, missingness, consistency) at every or most layers.

A plausible implication is more interpretable architectures for domains where feature attributions and compliance with explainability standards are critical, without sacrificing efficiency, trainability, or expressivity (Wang et al., 2021).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Shapley Transform.