Comparing Sensor Relationships, Not Sensor Values: Matched-Reference Siamese Graphs for Industrial Anomaly Detection

Many of the hardest failures in plants, water networks and spacecraft leave every individual sensor inside its normal range. What breaks is the relationship between sensors: a pump's flow stops tracking the tank level, or a valve reading stops matching downstream pressure. Most deep detectors still look for anomalies indirectly. They predict or rebuild the raw signals and flag large errors. A well-trained model can rebuild odd data almost as well as normal data, and a plant that legitimately switches operating mode also produces large errors. We propose to detect anomalies by direct comparison instead. For each incoming window of sensor data, we retrieve a past normal window in which every sensor sat at similar levels. We pass both windows through the same graph-based encoder, a "Siamese" network (two copies of one network with identical weights). We then score how much each sensor's relationships to the other sensors differ between the two windows.

The two-sentence version is this. Match the current window to a normal historical window by what each sensor reads on its own, then compare the two windows by how the sensors relate to each other, using one shared learned encoder. Because the match is made on individual readings, the comparison isolates exactly the "values look fine, relationships are broken" failures the field cares about. Because the differences are computed per sensor, the same score also points to which sensors misbehaved.

Core Claim

Our claim is about what the shared weights buy. A raw comparison of correlation matrices also reacts to harmless relationship changes, such as wear, seasonal load and phase switches. A weight-sharing encoder trained on pairs of normal windows taken from different periods can learn to ignore those harmless changes, the way Siamese change detectors in remote sensing learn to ignore lighting and foliage. We also train it on pairs where cross-sensor coupling has been broken on purpose while each sensor's own statistics are kept intact. This should make it sensitive to the relational breakdowns that matter.

The claim is falsifiable against a specific, cheap competitor: the same retrieve-then-compare pipeline run on raw correlation matrices with no learning. If learning does not beat that, the proposal's central claim fails. We say so up front because it is the most likely way for this idea to be wrong.

Where This Sits

The relational view of anomalies motivates the work. MSCRED turns windows into inter-sensor correlation ("signature") matrices at several time scales and reconstructs them. It diagnoses root causes from rows of the residual matrix, but it remains a reconstruction model. GDN learns a sparse sensor graph, linking each sensor to its top-K most similar peers by trainable embedding. It scores anomalies by per-sensor forecasting error. SPAGD makes that graph change over time using reconstruction residuals. SPAGD and STEN both name the failure that motivates us: expressive reconstruction or prediction models rebuild anomalies too. STEN responds with self-supervised tasks: recovering shuffled subsequence order, and predicting pairwise distances under a random projection. It never compares a window against a reference.

Three works come closest by pairing branches, and each constrains our design differently. SSAD scores the disagreement (KL divergence) between a temporal branch and a sensor-attention branch. Its branches are structurally different, it compares two views of the same window rather than two windows, and it leaves sensor localization as future work. ScatterAD (also here; ScatterAD: Temporal-Topological Scattering Mechanism for Time Series Anomaly Detection) couples a graph-attention target encoder with a causal-convolution online encoder. The graph encoder is updated as a moving average of the online one, and normal data is pulled toward a fixed center on a hypersphere. That is an asymmetric twin over a static initial graph with no per-sensor attribution. Our twins are identical, see two different windows, and return per-sensor scores.

s-GNN is the nearest relative. It runs a weight-sharing graph network on two graph snapshots and pools the k largest node-wise embedding distances ("Sort-k") so that local changes are not averaged away. We reuse Sort-k directly. s-GNN, however, consumes pre-built graph snapshots, trains on spectral-clustering pseudo-labels, and compares against the preceding snapshot. We learn the graph from raw windows and supervise with marginal-preserving coupling breaks. Most importantly, we choose the reference by matching operating state rather than by recency. A recency reference flags every legitimate mode switch as a change.

From vision, the change-detection literature supplies the design argument. DASNet shows that weight-sharing branches with a margin-based contrastive loss suppress harmless "pseudochanges." A Change Detection Reality Check shows that a plain, well-tuned difference-based Siamese U-Net matches or beats elaborate attention models: 82.02 versus 75.65 F1 for ChangeFormer on a clean WHU-CD split. That pushes us toward a simple symmetric encoder with a subtraction head, not an elaborate one. FewSOME supplies a fallback against the network mapping everything to one point (collapse): a stop-gradient anchor that pulls normal samples together without needing negatives. Finally, TimeSeAD constrains our evaluation. It shows that under "point adjustment" scoring, a random signal reaches nearly 90% F1, and that the common benchmarks shift between train and test. It also finds that simple LSTM autoencoders and GDN are among the most consistent models.

Research Program

The encoder is a single graph network applied identically to any window of $N$ sensors over $T$ steps. Each sensor has a trainable embedding, and a sparse directed graph links each sensor to its top-K neighbors, as in GDN. Each sensor's history passes through a small temporal convolution, and two rounds of graph attention mix in neighbor information. The output is one vector $h_i(W)$ per sensor $i$, which describes that sensor in the context of its neighbors. The graph is learned jointly and shared by both branches, so cost grows as $O(NK)$ rather than the $O(N^2)$ of full signature matrices.

Reference retrieval deliberately uses different information from comparison. We keep a memory bank of normal training windows indexed by per-sensor summary statistics: mean level, spread, and slope of each channel, normalized. For a query window we retrieve its nearest bank entries $R$ under this marginal-only index. This finds a normal moment when every sensor read about the same, approximating the same operating state. An attack that keeps values in range will therefore still retrieve a well-matched reference, and the comparison then exposes the relational break.

The per-sensor discrepancy is $d_i = \lVert h_i(W) - h_i(R) \rVert$. The window score averages the $k$ largest $d_i$ (Sort-k), and the sorted $d_i$ themselves are the localization output.

Training uses only normal data plus synthetic coupling breaks. Positive pairs are a normal window and a marginal-matched normal window from a different period, ideally from a different week or regime, so the encoder learns which relationship changes are harmless. Negative pairs take a normal window and corrupt a random subset $S$ of sensors in ways that keep each corrupted sensor's own distribution but break its relation to the rest. The corruption families are time-shifting the sensor, substituting the same sensor's signal from another normal time with matched marginals, and phase-randomizing it. The loss is a per-sensor margin loss:

$$ \mathcal{L} = \sum_{i \notin S} d_i^2 + \sum_{i \in S} \max(0,\, m - d_i)^2, $$

where $m$ is a margin. In positive pairs every sensor falls in the first sum. This gives sensor-level supervision for free and prevents collapse, since corrupted sensors must stay at least $m$ apart. FewSOME's stop-gradient anchor is kept as an ablation in case the negatives prove too easy.

To test whether the model learns "broken coupling" in general rather than memorizing one corruption, we always hold out one corruption family at training time and evaluate on it.

Baselines

The naive reference point is a detector that flags windows whose individual sensors leave their training range, using per-channel z-score thresholds. It is paired with TimeSeAD's random-score check. If the proposal's gains appear under a metric where these also score well, the metric is broken, not the baseline.

The most dangerous baseline is the same pipeline with learning removed. The same marginal-matched retrieval is run, but the comparison is between raw multi-scale correlation matrices in MSCRED's signature-matrix style. Per-sensor discrepancy is the norm of each row's difference, followed by the same Sort-k pooling. It shares our data, our retrieval, and our scoring. Its only tunable parameters are window scales, number of references and $k$, which receive the same validation search as our model. Beating it means a clear gain in unadjusted event-level F1 and AUC-PR on at least three of the five datasets, with error bars over five seeds, and better localization.

The strongest existing methods are GDN, SPAGD and ScatterAD. GDN is included because TimeSeAD singles it out as consistently strong. Its paper reports F1 0.81 on SWaT and 0.57 on WADI. SPAGD reports AUC 86.30% on SWaT. For ScatterAD, no reported F1/AUC number on SWaT or WADI was found on Lacuna. For SMD, PUAD (Prototype-oriented unsupervised anomaly detection) reports F1 96.16%, and we include it there.

These reported numbers come from heterogeneous protocols, likely including point adjustment, so we do not compare against them directly. All baselines are rerun from released code under identical splits, window lengths, a fixed hyperparameter-search budget of the same number of trials per method, and the same GPU-hour cap. LSTM autoencoder is included because TimeSeAD finds it competitive. MSCRED is included for localization.

Two ablations isolate the key ingredients. The first is a single-branch early-fusion model: the current and reference windows are concatenated along the channel axis and trained with the same corruption negatives and per-sensor labels, isolating weight sharing. The second replaces marginal-matched retrieval with the immediately preceding window, as in s-GNN, isolating reference selection. Secondary ablations swap Sort-k for the mean, use same-period instead of cross-period positives, and use the stop-gradient anchor instead of negatives.

Why not just…?

Why not just difference raw correlation matrices against the matched reference? This is the real threat, and the experiment is built around it. On a stationary plant with few regimes, raw correlation differences may be as good as anything learned, since the matched reference already removes the mode effect. Our bet is that learning helps on long test periods with drift, where harmless correlation changes accumulate. We will report the gap separately for test segments near and far in time from training. If the learned model only wins far from training, that is a narrower but honest result. If it never wins, we will report that the retrieval step, not the Siamese encoder, carries the value.

Why not just use GDN-style forecasting error or an LSTM autoencoder? Both score how well the raw values are predicted, which is the reconstruction failure that SPAGD and STEN describe. MSCRED reports LSTM-ED trailing correlation-aware modeling and degrading under noise. Still, TimeSeAD's finding that these simple models are consistently strong is a fair warning. They are rerun under our protocol, and the synthetic in-range coupling-break test set is designed to show directly whether value-prediction errors miss attacks that relational comparison catches.

Why not just train one network on the concatenated pair, or even on the current window alone, using the same synthetic negatives? If the corruption negatives do all the work, the twin structure is decoration. The early-fusion ablation answers this. The vision evidence from DASNet and the Reality Check paper predicts that shared weights will generalize better to harmless shifts. We will measure it on the held-out corruption family and on the drifted test segments, where that difference should show.

Why not adopt ScatterAD's asymmetric temporal/graph twins? ScatterAD compares two views of one window against a fixed center. It cannot say which sensor caused a deviation and cannot exploit a matched reference. It is run as a baseline, and the localization comparison is where we expect the symmetric per-sensor design to differ most.

Proposed Experiments

We use SWaT and WADI because they contain cyber-physical attacks of exactly the in-range kind. SMD and Exathlon are included because TimeSeAD recommends them as less shift-prone, and MSL is reported with TimeSeAD's caveats noted. Point adjustment is never used. We report unadjusted event-level F1, affiliation F1 (as used by ScatterAD), AUC-PR, and the random-score check, all over five seeds with paired significance tests.

Localization is scored as top-3 hit rate of the true sensor, in two settings. The first injects held-out coupling breaks into normal test data, where ground-truth sensors are known. The second uses those SWaT and WADI attacks whose documentation names a targeted component, restricted to attacks where that mapping is unambiguous. Localization is compared against MSCRED residual rows, GDN per-sensor errors, and the raw-correlation baseline.

Three checks decide the outcome. The first is whether the learned Siamese model beats the no-learning matched-reference baseline, and specifically on test segments far from training, which tests the core claim. The second is whether it beats the early-fusion model on the held-out corruption family, which tests whether shared weights matter. The third is whether marginal-matched retrieval beats preceding-window references around operating-mode switches, which we identify by clustering marginal statistics. That tests the reference design. A positive result on all three would establish relational comparison against matched references as a distinct detection strategy. A negative result on the first would redirect the work toward the retrieval idea alone.