Papers
Topics
Authors
Recent
Search
2000 character limit reached

CPAC: Causal Prototype Attention Classifier

Updated 6 July 2026
  • CPAC is a prototype-based attention framework that uses query-key-only mechanisms for interpretable classification in EEG and fraud detection.
  • It features distinct variants with fixed or learnable prototypes that guide decisions via attention routing or distance weighting.
  • Empirical results reveal trade-offs between interpretability and performance, making CPAC a deployment-friendly, calibration-free model.

Searching arXiv for the cited CPAC-related papers and closely related context. Found the main ERP-XTTN paper and the fraud-detection CPAC paper; also checking baseline/context papers for naming consistency. The Causal Prototype Attention Classifier (CPAC) denotes a prototype-based attention paradigm that appears in two distinct arXiv formulations. In ERP-XTTN, CPAC is the classifier component of an interpretable, calibration-free architecture for cross-subject event-related potential classification, implemented through query-key-only cross-attention with no value projection so that classification depends entirely on attention routing and attention faithfulness is structural rather than post-hoc (Wyman et al., 1 Jun 2026). In fraud detection, CPAC is an interpretable latent classifier coupled to a VAE-GAN encoder, using prototype-based attention mechanisms to promote class-aware clustering and improved latent space structure under extreme class imbalance (Giusti et al., 19 Jul 2025). The shared theme is prototype-guided decision making; the operational form, learning objective, and meaning of “causal” differ materially across the two settings.

1. Terminological scope and architectural variants

The term CPAC does not refer to a single invariant neural module. In the ERP setting, it is instantiated as a cross-attention architecture that routes input EEG patches to fixed difference-wave prototypes via query-key-only cross-attention with no value projection. In the fraud setting, it is instantiated as a prototype bank together with an attention module that produces a feature-wise attention mask and a classifier defined by weighted distances to class prototypes (Wyman et al., 1 Jun 2026).

Aspect ERP-XTTN CPAC Fraud-detection CPAC
Input representation EEG epoch patches Latent vector zz
Prototype type Fixed difference-wave prototypes Two learnable vectors in Rd\mathbb{R}^d
Decision mechanism Flattened attention routing matrix AA Softmax over negative weighted distances

This suggests a family resemblance rather than a single canonical architecture. In both formulations, prototypes act as anchors for class-relevant structure, but the ERP variant makes attention itself the sole evidentiary pathway, whereas the fraud variant uses attention to gate per-dimension distances to prototypes. A plausible implication is that “CPAC” is best understood as a design pattern centered on prototype-conditioned routing or distance weighting, rather than as one fixed network topology.

2. Query-key-only CPAC in ERP-XTTN

In ERP-XTTN, an input EEG epoch is defined as XRC×TX\in\mathbb{R}^{C\times T}, with CC channels and TT time-samples. The epoch is chopped into NN non-overlapping patches of width pp samples; the configuration reported is p=8p=8 at 256 Hz N=25\rightarrow N=25. Each patch is flattened and linearly projected into a Rd\mathbb{R}^d0-dimensional patch embedding space, with Rd\mathbb{R}^d1, yielding

Rd\mathbb{R}^d2

For Rd\mathbb{R}^d3 fixed prototypes, prototype embeddings are formed as

Rd\mathbb{R}^d4

After a shared LayerNorm, ERP-XTTN computes multi-head query and key projections, with Rd\mathbb{R}^d5 heads and Rd\mathbb{R}^d6:

Rd\mathbb{R}^d7

The scaled dot-product attention weights are then

Rd\mathbb{R}^d8

where the softmax is taken row-wise over prototypes, and the final routing matrix is the head average

Rd\mathbb{R}^d9

The interpretation given is that AA0 is the fraction of attention that patch AA1 routes to prototype AA2 (Wyman et al., 1 Jun 2026).

The defining restriction is the removal of the value pathway: No separate “value” projection is used: AA3 itself is the sole input to the classifier head. After averaging heads, the model flattens AA4 to a vector AA5 and applies one linear layer,

AA6

Training uses binary cross-entropy-with-logits loss on AA7, and inference thresholds AA8 for a class label. The implementation details specify Self-attention: one layer, pre-norm, AA9 heads, dropout=0.3 on weights, residual connection; Cross-attention: separate LayerNorm for queries/keys, XRC×TX\in\mathbb{R}^{C\times T}0 projections, no values; and Classifier: flatten XRC×TX\in\mathbb{R}^{C\times T}1 vector of length XRC×TX\in\mathbb{R}^{C\times T}2. Because the classifier has no alternative access path to the input, the paper characterizes attention faithfulness as structural rather than post-hoc.

3. Prototype construction and deployment-compatible preprocessing

ERP-XTTN derives prototypes automatically from the grand-average difference wave within each leave-one-subject-out (LOSO) training fold. For a single detection channel XRC×TX\in\mathbb{R}^{C\times T}3, the fold produces two class means, XRC×TX\in\mathbb{R}^{C\times T}4 for positive trials and XRC×TX\in\mathbb{R}^{C\times T}5 for negative trials, and defines the difference wave as

XRC×TX\in\mathbb{R}^{C\times T}6

This signal is smoothed by a Gaussian (XRC×TX\in\mathbb{R}^{C\times T}7 samples), after which the algorithm detects up to XRC×TX\in\mathbb{R}^{C\times T}8 extrema of both polarities after XRC×TX\in\mathbb{R}^{C\times T}9 ms, requiring prominence CC0 and within-polarity separation CC1 ms. For each selected peak at time CC2, the method identifies the previous and next zero crossings, clamps the window width to CC3 about CC4, and stores the full-montage CC5 over CC6 channels restricted to the resulting window as a prototype tensor CC7 (Wyman et al., 1 Jun 2026).

Prototype embedding uses exactly the same patch-splitting + linear projection as on CC8, followed by mean pooling over the prototype’s own patches to yield the final CC9. The implementation note states that each prototype TT0 is stored as a TT1 tensor (raw TT2-wave segments); embedding is computed on the fly with the same projection as for input patches.

The preprocessing pipeline is explicitly causal. Every dataset is processed by a 4th-order Butterworth bandpass at 1–10 Hz, implemented as a causal IIR filter such as lfilter(b,a,x), with difference equation

TT3

and no backward pass, so TT4 depends only on past and present samples. The data are then downsampled to 256 Hz (where needed) and epoched from 0–800 ms post-trigger. The paper frames these choices as deployment-compatible conditions and evaluates them under zero calibration and LOSO generalization. A common misconception would be to read “causal” here as causal discovery; in this formulation, the primary concrete use of the term is causal signal processing and temporally valid deployment.

4. Latent prototype-distance CPAC for fraud detection

In the fraud-detection formulation, CPAC is defined around four components: an Encoder TT5, a prototype bank TT6, an Attention module TT7, and a Distance Aggregator + Classifier head. The encoder produces a TT8-dimensional latent vector TT9 (or NN0); the prototype bank consists of two learnable vectors in NN1 that serve as class “anchors” (non-fraud vs. fraud); and the attention module is a small MLP that ingests NN2 and outputs a per-dimension gating vector NN3 (Giusti et al., 19 Jul 2025).

The mathematical specification is explicit. The attention mechanism is

NN4

and, for each class NN5, the weighted distance is

NN6

where NN7 is a learned scalar controlling sensitivity. These distances are converted to soft assignments by

NN8

The final fraud probability is

NN9

or equivalently, with logits pp0,

pp1

The paper states that causal reasoning is invoked by viewing each attention weight pp2 as an estimate of the “causal effect” of latent feature pp3 on the final decision, while prototypes provide counterfactual anchors. In this setting, therefore, “causal” is not the same notion as in ERP-XTTN’s causal IIR preprocessing. Rather, the term is used to organize interpretation around feature-level influence and counterfactual prototype comparison. This suggests that the causal semantics of CPAC are domain-specific and should not be treated as a single formal causal framework.

5. Training objectives, latent shaping, and empirical behavior

The ERP-XTTN training regimen specifies AdamW with lr=pp4, weight_decay=pp5, batch size 128, class-weighted BCE-with-logits; pos_weight=(#negative)/(#positive), linear warmup for 5 epochs pp6 cosine annealing for 100 epochs pp7 constant at pp8, gradient clipping pp9, dropout 0.3 after patch embedding and on attention weights, training-only augmentation through temporal jitter in p=8p=80 samples and additive Gaussian noise p=8p=81, and early stopping with a 15% holdout stratified by subjectp=8p=82class, monitored by LOSO-validation AUROC, with patience=15 epochs and max_epochs=250. The final model is retrained from scratch on train+val for the chosen epoch count (Wyman et al., 1 Jun 2026).

The fraud formulation introduces a broader objective because CPAC is attached to a VAE-GAN encoder. The stated losses are

p=8p=83

p=8p=84

p=8p=85

p=8p=86

For CPAC itself, the paper uses Binary Cross-Entropy or Focal Loss:

p=8p=87

together with an attention-scale penalty

p=8p=88

and a prototype-anchoring penalty

p=8p=89

The combined CPAC head loss is

N=25\rightarrow N=250

When attached to the VAE-GAN encoder, training alternates between minimizing N=25\rightarrow N=251 and minimizing N=25\rightarrow N=252, or, in a single-objective view,

N=25\rightarrow N=253

The latent-space interpretation is stated directly: The BCE/Focal loss through CPAC backpropagates into the encoder, explicitly pulling latent vectors N=25\rightarrow N=254 toward their class prototype N=25\rightarrow N=255; the anchoring term N=25\rightarrow N=256 further encourages each prototype N=25\rightarrow N=257 to track the empirical centroid of class-N=25\rightarrow N=258 latents; and as a result, N=25\rightarrow N=259’s form two tight, well-separated clusters, each around Rd\mathbb{R}^d00 or Rd\mathbb{R}^d01. Cluster separation is described as quantifiable by the Silhouette Score or Davies–Bouldin Index, while the paper visualizes overlap using PCA and 3D plots.

6. Performance, interpretability, limitations, and common misconceptions

In ERP-XTTN, CPAC is benchmarked against EEGNet and xDAWN+Riemannian-geometry (xDAWN+RG) under a targeted 3-channel montage and a full available montage. The reported mean LOSO AUROC across 9 datasets is:

Setting xDAWN+RG EEGNet ERP-XTTN
3-channel .715 .731 .716
full montage .777 .794 .766

The corresponding interpretability cost is reported as Rd\mathbb{R}^d02 at 3 channels and Rd\mathbb{R}^d03 at full montage. The paper states that the mean gap arises from two largely distinct sources: a temporal-flexibility cost relative to EEGNet and a spatial-exploitation cost relative to xDAWN+RG, the latter driven by signal-to-noise ratio at full montage, while also noting that on some tasks (e.g. ERN, P300, HRI-ErrP at 3ch) ERP-XTTN actually slightly outperformed xDAWN+RG (Wyman et al., 1 Jun 2026).

ERP-XTTN’s interpretability is quantified using two trial-level routing metrics: Attention entropy

Rd\mathbb{R}^d04

averaged over trials, and Routing discriminability Rd\mathbb{R}^d05, defined as the mean cosine distance between class-mean attention vectors. The paper reports that the average interpretability cost Rd\mathbb{R}^d06 against EEGNet correlates (Spearman Rd\mathbb{R}^d07) with Rd\mathbb{R}^d08, Rd\mathbb{R}^d09, and an SNR proxy (grand-average Rd\mathbb{R}^d10-wave amplitude / trial-wise SD), suggesting that the fixed-prototype constraint costs most when the temporal signal is strong and narrowly peaked. Against xDAWN+RG, Rd\mathbb{R}^d11 correlates most with SNR in the full-montage case, indicating that spatial filtering outperforms static prototypes when there is rich spatial information. The grand-average waveform analysis further reports that the TP–FP correlation (mean Pearson Rd\mathbb{R}^d12) exceeds the TP–TN correlation on most datasets, which the paper interprets as evidence that misclassifications occur on trials whose morphology genuinely resembles the target prototype set.

In the fraud setting, the reported standalone CPAC metrics on raw data are Precision=87.20%, Recall=73.65%, F1=79.85%, AUC=95.80%. When used in VAE-GAN+CPAC as an oversampler, the paper states that the best setting (75 pre-SMOTE + VAE-GAN+CPAC) yields: Precision≈96.4%, Recall≈90.2%, F1≈93.1%, AUC≈96.9%, and the abstract summarizes this as an F1-score of 93.14\% percent and recall of 90.18\%, along with improved latent cluster separation. The ablation study reports that removing the CPAC head causes latent clusters collapse, heavy overlap, poor downstream accuracy; removing attention (Rd\mathbb{R}^d13) degrades separation to a near-linear manifold; removing prototypes causes clusters to overlap badly; omitting scale/anchor penalties leaves clusters separated but with fuzzier boundaries; and swapping BCERd\mathbb{R}^d14Focal Loss gives sharper latent separation visually but slight drop in raw F1 on hold-out (Giusti et al., 19 Jul 2025).

Several misconceptions can be addressed directly from these results. First, CPAC is not synonymous with lossless interpretability: the ERP evidence reports a measurable interpretability cost. Second, the causal label is not uniform across domains: ERP-XTTN grounds it in causal IIR preprocessing and deployment compatibility, whereas the fraud paper grounds it in feature-level “causal effects” and counterfactual anchors. Third, prototype guidance does not eliminate the need for domain structure: the ERP paper identifies limits associated with temporal flexibility and spatial exploitation, while the fraud paper explicitly lists one prototype per class, hyperparameter sensitivity, and possible extensions to multiple prototypes, contrastive or manifold regularization, denoising autoencoders, and application to network intrusion or medical outliers. Taken together, these studies position CPAC as an interpretable prototype-attention framework whose practical behavior depends strongly on how prototypes are defined, how attention is constrained, and which notion of causality is being invoked.

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 Causal Prototype Attention Classifier (CPAC).