Scientific Machine Learning • Undergraduate Research
Surrogate models replace expensive physics simulations, but standard regression networks give no warning when evaluated outside their training distribution. By adding a single checknode to the output layer and training it with a specialized loss, the network's outputs disagree when presented with out-of-distribution inputs. This internal disagreement serves as an immediate detection flag during standard inference, achieving 99.66% AUROC on a 0D combustion dataset.
This runs the actual trained sum-checksum model in your browser with Pyodide and NumPy. Load it, then move the query point around the 2D toy domain. Inside the in-distribution disk the three predicted outputs stay consistent with the checknode, so the checksum error stays low; drag outside and the predictions break down and the error explodes. The domain, the three outputs, and this error map are the setup described in the Toy Problem section below.
| Output | True f(x) | Model ŷ |
|---|---|---|
| y1 = sin x1 + cos x2 | – | – |
| y2 = x1 · x2 | – | – |
| y3 = e−(x1²+x2²) | – | – |
Surrogate models train on expensive physics simulations to provide fast approximations. However, standard regression models output point estimates without built-in confidence metrics or error bounds. If given an input outside their training space, they still return a concrete value without signaling uncertainty.
Detecting these out-of-distribution (OOD) points prevents invalid estimates from propagating through larger engineering workflows. Established approaches like deep ensembles, Monte Carlo dropout, and Bayesian neural networks provide uncertainty metrics, but require running multiple inference passes or training separate models.
This method adapts checksum principles from data communication. An extra output node (the checknode) is added to the network and trained to predict a deterministic function of the primary outputs, such as their sum. For in-distribution inputs, the checknode closely matches the computed sum, keeping the checksum error low. On unfamiliar inputs, the checknode and primary outputs extrapolate differently, causing the checksum error to spike. This discrepancy functions as an OOD flag produced directly within a single forward pass.
Evaluated on a 0D auto-ignition combustion dataset (with in-distribution defined as peak temperatures below 2500 K), the tuned sine checksum clearly separates ID from OOD points while preserving baseline regression accuracy.
Because the checksum function operates strictly on the model's outputs rather than intermediate weights or inputs, the score requires no auxiliary models, sampling passes, or calibrated distance metrics. The computational overhead is limited to evaluating one extra node and a final difference calculation.
Consider a simple 1D example: a network trained to approximate $y=x$ on the interval
$0
In general, bare regression outputs cannot distinguish valid interpolations from untrustworthy extrapolations.
Standard methods quantify uncertainty through repeated evaluation or ensemble sampling. Bayesian neural networks sample from learned weight distributions, Monte Carlo dropout aggregates multiple stochastic forward passes, and deep ensembles measure variance across several distinct models. While effective, these techniques multiply training and inference overhead. In classification, methods such as Outlier Exposure and energy-based models structure training so the network explicitly responds differently to out-of-distribution inputs. We apply a similar philosophy to regression without adding inference passes.
First formalized for serial data transmission by Fletcher in 1982, checksums append verification bytes so receivers can detect data corruption through consistency checks. Traditional checksums are binary (matching or failing), which is impractical for regression models that inherently carry small residual errors. The soft checksum instead uses the continuous magnitude of the mismatch between the predicted checknode and the computed output function as a graded OOD metric.
For a regression network mapping inputs to outputs, $\hat{\mathbf y} = \hat f(\mathbf x;\,\boldsymbol\theta)$, the output layer is expanded by one node to produce both the target predictions and an estimated checksum $\hat{\mathbb C}_y$.
The checksum function $\mathbb C$ is a fixed, deterministic mapping over the predicted outputs. While a simple sum provides a straightforward baseline, composing the sum with a sine function introduces nonlinearity that improves sensitivity. The checksum error is defined as the absolute difference between the checknode output and the evaluated checksum function.
Because $\mathbb C$ requires only the model outputs, this metric can be computed directly at inference time without reference labels.
Training optimizes a multi-objective loss function. The primary term is standard mean-squared error (MSE) on the physical target predictions.
The checksum loss $(\alpha)$ fits the checknode to the checksum of the ground-truth targets, while the checksum penalty $(\beta)$ penalizes discrepancies between the checknode and the predicted outputs to maintain internal consistency across the training distribution.
On out-of-distribution samples, the checksum reward $(\gamma)$ encourages discrepancy between the checknode and the predicted checksum. A reciprocal formulation bounded by $\kappa$ and stabilized by $\mu$ prevents gradient instability once separation is established.
In-distribution data flows through the prediction, checksum loss, and penalty terms; generated OOD data is routed strictly through the reward term. The losses sum into a single scalar for backpropagation.
| Term | Weight | Data | Objective |
|---|---|---|---|
| Prediction (MSE) | 1.0 | ID | Fits the surrogate to target data |
| Checksum loss | α | ID | Aligns checknode with ground-truth checksum |
| Checksum penalty | β | ID | Enforces consistency between predictions and checknode |
| Checksum reward | γ | OOD | Maximizes output discrepancy on OOD points |
OOD samples are synthesized on the fly from the training data envelope. For each generated point, a subset of input dimensions is sampled outside the observed $[\min,\max]$ range while remaining dimensions stay within range. An ID Max parameter controls how many dimensions may remain in-distribution: forcing every dimension out produces corner points far from the distribution, while allowing some dimensions to stay in range seeds points along the immediate decision boundary.
Synthetic OOD points are used solely within the reward loss calculation; they do not enter the prediction or penalty loss terms.
A 2D toy problem allows direct visualization of the error surface across the entire domain. Evaluating the network on a uniform grid clarifies how the checksum response relates to input distance from the training manifold. You can explore this exact error surface, output by output, in the interactive demonstration at the top of the page.
The in-distribution dataset is defined as a cluster of 2D points near the origin. Each point maps to three distinct functional outputs (periodic, multiplicative, and radial decay) to ensure the checksum does not exploit trivial linear relationships.
Evaluating the model across the domain $x_1, x_2 \in [-1, 1]$ shows that checksum error correlates closely with actual prediction error on a log-log scale. As prediction error increases in extrapolation regions, the checksum error rises proportionally without requiring access to true reference labels.
The benchmark is a 0D auto-ignition combustion problem solved with Cantera. Seven chemical species ($C_2H_4,\ O_2,\ H_2,\ CO,\ CO_2,\ H_2O$ and inert $N_2$) interact across three primary reaction pathways. The surrogate model predicts net species production rates $\omega$ from temperature, pressure, and composition. Trajectories with peak temperatures below 2500 K constitute in-distribution data, while hotter states are withheld as out-of-distribution targets.
Network architecture: 3 hidden layers (256 units each), learning rate $10^{-4}$, batch size 256, 1500 epochs. All reported values represent five-run averages to account for weight initialization variance.
| Configuration | FNR 99% ↓ | AUROC ↑ | ID error ↓ | Note |
|---|---|---|---|---|
| Baseline, summation (α,β,γ = 0) | 56.98% | 87.86% | 3.07×10⁻⁴ | Untrained checknode |
| Baseline, sine (α,β,γ = 0) | 90.17% | 60.16% | 2.86×10⁻⁵ | No separation signal |
| Summation, α = 1, γ = 1 | 5.51% | 98.74% | 7.16×10⁻⁵ | Low-complexity configuration |
| Sine, α = 1 (loss only) | 1.88% | 99.65% | 1.11×10⁻⁴ | Lowest false negative rate |
| Sine, α = 1, γ = 1 | 1.89% | 99.66% | 1.02×10⁻⁴ | Highest overall AUROC |
Best values per column are highlighted in blue. The summation checksum offers consistent baseline accuracy with low implementation complexity, whereas the sine checksum achieves higher detection sensitivity at a slight trade-off in in-distribution error stability. The complete eight-weight ablation is detailed in the full paper.
Plotting checksum error against prediction error highlights the impact of the loss formulation. In an effective detector, OOD points exhibit elevated checksum error alongside prediction error. Without checksum training, the errors remain uncorrelated; incorporating the loss and reward terms aligns them along a clear diagonal, isolating OOD cases.
Green points represent in-distribution validation data, red points indicate inaccurate OOD predictions, and blue points denote accurate OOD predictions. The green bounding box marks the accepted region, while the red box highlights unflagged predictions with high error. Checksum training significantly reduces false acceptances in the critical upper-left region.
During inference, evaluation requires only a single forward pass. The network computes target predictions and the checknode simultaneously, after which the checksum function is evaluated. If the calculated difference remains below the threshold, the prediction is accepted; if it exceeds the threshold, the sample is flagged for review or routed to a full physics simulation.
The in-distribution threshold here is defined by a fixed temperature cutoff (2500 K), which creates a clear benchmark but simplifies boundary definitions found in more complex domains. While the sine checksum provides higher detection sensitivity, the summation checksum offers a more stable baseline for tasks prioritizing raw regression precision. Future work will benchmark these configurations directly against deep ensembles and MC dropout, test alternative nonlinear checksum functions, and evaluate multi-node verification architectures.