---
title: Physics-Based Loss Function in Scientific ML
url: https://www.emergentmind.com/topics/physics-based-loss-function
type: topic
---

# Physics-Based Loss Function in Scientific ML

Physics-based loss function denotes a training objective whose semantics are supplied by the scientific system itself rather than by generic prediction error alone. Across the literature, such losses are built from governing partial differential equations, boundary and initial conditions, variational energies, conservation laws, acquisition operators, or task-specific scientific figures of merit; accordingly, they define correctness through physical admissibility, measurement consistency, or domain utility instead of only through mean squared error or cross-entropy against labels [2602.05849], [1909.01394], [2412.09500], [2511.02087]. In contemporary scientific machine learning, the term therefore covers a broad family of objectives, from the squared residual strong-form loss and the Deep Ritz energy in PINNs to line-integral projection losses for PET attenuation correction, significance-aware surrogates in collider event classification, and local energy losses for molecular and spin systems [2602.05849], [1909.01394], [2412.09500], [2511.02087].

## 1. Conceptual scope and distinction

In the PDE-centered formulation used in physics-informed neural networks, a physics-based loss is “a training objective built directly from the governing physics—typically a PDE and its associated boundary conditions or variational structure—rather than from labeled input-output data alone” [2602.05849]. That definition captures the canonical case, but the broader literature extends the same principle to other scientific settings. In medical imaging, the loss may be defined in the projection domain because attenuation correction depends on line integrals rather than voxelwise errors [1909.01394]. In high-energy physics, it may be derived from the approximate median significance \(Z \approx N_s/\sqrt{N_b}\), because discovery sensitivity rather than average classification accuracy is the relevant terminal objective [2412.09500]. In atomistic learning, it may arise from a local Boltzmann model centered on each sample, which turns supervised training into minimization of an approximate physical energy difference [2511.02087].

This breadth matters because “physics-based” does not identify a single mathematical template. Some objectives enforce laws directly through residuals or balance relations; others encode invariants, energy conservation, or measurement operators; still others reweight errors toward physically decisive regions, such as the recirculation bubble in rarefied micro-step flow [2509.17254]. A plausible implication is that the term is best understood functionally: a loss is physics-based when its penalty structure is induced by quantities that already have scientific meaning in the target domain.

The literature also draws an important negative distinction. In the Deep Physics Corrector for stochastic differential equations, physics enters primarily through the gray-box model architecture and rollout dynamics, while the training objective is conditional maximum mean discrepancy; the method is therefore a physics-enhanced model with a statistical loss rather than a residual-based physics-loss framework [2209.09750]. This distinction separates physics in the model from physics in the objective.

## 2. Principal mathematical formulations

The most common formulation is strong-form residual minimization. If a neural field \(u(\cdot;\theta)\) approximates the solution of a PDE with differential operator \(\mathcal D\) and source term \(s\), the loss can be written as
\[
\mathcal L(\theta)=\frac12\int_\Omega \|\mathcal D[u(\cdot;\theta)]-s\|^2\,d\Omega.
\]
For Poisson-type problems, this becomes the familiar squared \(L^2\)-norm of the PDE residual; in PINNs this residual is typically combined with initial- and boundary-condition penalties or enforced through architectural constraints [2602.05849].

A second canonical formulation is variational or energy minimization. In the Deep Ritz method, training minimizes an energy functional rather than a squared strong-form residual:
\[
\Pi(\theta)=\int_\Omega \text{energy density} - \text{loading term}.
\]
For the one-dimensional elliptic benchmark studied in the loss-landscape literature,
\[
\Pi(\theta)=\int_0^1 \left[\frac{1}{2}\left(u_x(x;\theta)\right)^2-f(x)\,u(x;\theta)\right]\,dx,
\]
whereas the corresponding strong-form PINN objective is
\[
\mathcal L(\theta)=\frac{1}{2}\int_0^1 \left(u_{xx}(x;\theta)+f(x)\right)^2\,dx.
\]
The two formulations differ structurally because Deep Ritz lowers the order of differentiation, while the strong-form loss enforces the PDE pointwise in the \(L^2\) sense [2602.05849].

A third formulation derives the loss from a probabilistic equilibrium model. In “Energy Loss Functions for Physical Systems,” the conditional uncertainty around a target configuration \(y\) is modeled as
\[
p(\hat y\mid y)=\frac{\exp\{-E(\hat y,y)/T\}}{Z(y,T)},
\]
which yields the reverse-KL objective
\[
\mathcal J(\theta)=\sum_i \frac{E(\hat y_\theta^{(i)}, y^{(i)})}{T}+\log Z(y^{(i)},T).
\]
Since the partition function does not depend on \(\theta\), optimization reduces to minimizing the physically chosen energy \(E(\hat y,y)\). In the atomistic case, the principal instantiation is a pair-distance energy,
\[
E(\hat{y}, y)=\sum_{i,j} \frac12 k_{ij}(y)\left(\|y_i-y_j\|-\|\hat y_i-\hat y_j\|\right)^2,
\]
which is invariant to Euclidean motions and to appropriate automorphisms of the distance graph [2511.02087].

Other formulations remain simpler but are still physically motivated. In mechanics prediction, one can augment mean-squared error by “a measure of the difference in the energy between the input and output states,” thereby enforcing conservation of energy without constructing PDE residuals [2105.00075]. In “Molecular Learning Dynamics,” the learned object is itself a type-specific scalar loss \(H_{\mathcal A_k}(\varphi)\), whose gradient plays the role of an effective force, so that \(M_{\mathcal A_k}\ddot q=-\nabla H_{\mathcal A_k}\) parallels the usual \(M\ddot q=-\nabla V\) correspondence between mechanics and potential energy [2504.10560].

## 3. PINNs, mixed formulations, and loss construction

In standard PINNs, the data and physics terms are usually written as
\[
\mathcal L_{\mathcal D}(\theta)=\frac{1}{N_\mathcal D}\sum |e_i|^2,\qquad
\mathcal L_{\mathcal F}(\theta)=\frac{1}{N_\mathcal F}\sum |f_i|^2,
\]
with scalarized objective
\[
\mathcal L(\theta;\alpha)=\alpha\mathcal L_{\mathcal D}(\theta)+(1-\alpha)\mathcal L_{\mathcal F}(\theta),\qquad \alpha\in(0,1).
\]
The multi-objective interpretation is central: the apparent trade-off between data fitting and physics enforcement is not fixed, because system parameters, domain size, and nondimensionalization rescale the residuals through the chain rule. For diffusion, the paper identifies the scale ratio \(f_i/e_i\sim \kappa/L^2\); for the steady Navier–Stokes example, \(f_i/e_i\sim 1/L^2\). The resulting “apparent Pareto front” is defined as the set of loss values achievable with gradient-based optimization [2105.00862].

Alternative residual constructions modify how the physics term is computed rather than what it represents. In FDM-PINN, the PDE loss is evaluated by finite-difference stencils on a regular grid instead of by automatic differentiation. The total loss remains
\[
L_{\text{PINN}}=L_\mu+\lambda L_f,
\]
but \(L_f\) is formed from discrete residuals such as the five-point Laplacian for Laplace’s equation or finite-difference approximations of \(u_t\), \(u_x\), and \(u_{xx}\) for Burgers’ equation [2602.21590].

A different reformulation removes the explicit initial- and boundary-condition penalties. In “About optimal loss function for training physics-informed neural networks under respecting causality,” the original problem is extended with Heaviside functions so that initial and boundary conditions appear as distributional contributions inside a single generalized residual term. This produces a one-term residual loss in which Dirac contributions encode the initial and boundary data, and it motivates causal weighting schemes based on running averages, Heaviside factors, or Dirac-like weights over time slices [2304.02282].

The choice of residual norm is itself nontrivial. For high-dimensional nonlinear Hamilton–Jacobi–Bellman equations, the paper “Is \(L^2\) Physics-Informed Loss Always Suitable for Training Physics-Informed Neural Network?” proves that small \(L^2\) residual does not generally imply a small solution error. For the HJB class studied there, stability with \(L^p\) residuals requires \(p\) to be sufficiently large, and the authors argue that \(L^\infty\) is a better choice than the de-facto standard \(L^2\) loss; they then propose an adversarial max-residual training algorithm to approximate \(L^\infty\)-type minimization [2206.02016].

Loss scaling can also be derived from the PDE coefficients themselves. For mixed-formulation PINNs applied to neutron diffusion, Physics-Based Loss Scaling replaces the standard mixed residual norm by
\[
\mathcal{L}_{\mathrm{PBLS}}[\zeta]
=
\|\delta_e^{-1/2}(\nabla\cdot p + T_e\phi - S_f)\|^2
+
\|D^{1/2}(D^{-1}p+\nabla\phi)\|^2,
\]
where \(\delta_e\) is the diagonal part of the removal operator and \(D\) is the diffusion matrix. The paper states that this weighted norm is equivalent to the classical MF-PINN loss in the continuous sense but improves convergence and accuracy in one-group and multigroup, 2D and 3D neutron diffusion benchmarks [2604.25957].

A further variation moves the innovation to the data-side term. In meta-learning for parametric PDEs, the PDE residual loss is retained, but the standard initial/boundary-condition MSE is replaced during support-stage adaptation by a task-specific Generalized Additive Model fitted to the residuals. The resulting support loss becomes \(\mathcal L_{\text{PDE}}+\mathcal L_{\text{GAM}}\), while query performance is still evaluated with the conventional PINN objective [2412.00225].

## 4. Measurement-, decision-, and region-aligned objectives

Physics-based loss functions need not be equation residuals. In collider event classification, the training target can be derived directly from the search metric. “Loss function to optimise signal significance in particle physics” constructs a surrogate for the approximate median significance
\[
Z \approx \frac{N_s}{\sqrt{N_b}},
\]
where selected signal and background yields are weighted by process cross sections and luminosity. Because the resulting objective is a set function over false negatives and false positives, the authors use the Lovász extension of a submodular loss to obtain a differentiable surrogate that is explicitly aware of process rates; the paper’s central motivation is that “not all event rates are equal,” whereas ordinary binary cross-entropy treats events symmetrically unless manually reweighted [2412.09500].

In PET attenuation-map synthesis, the relevant physics lies in the acquisition operator. The proposed line-integral projection loss is
\[
L_{LIP}(X,Y)=\sum_k\sum_i \frac{\left([P_kX]_i-[P_kY]_i\right)^2}{N_k},
\]
with projection angles uniformly sampled over \(180^\circ\). The motivation is that attenuation correction depends on the line integral of \(\mu\) along a line of response rather than on voxelwise attenuation-map similarity. The resulting combined objective,
\[
L_{\text{TOTAL}}=L_{L1}+\lambda_1 L_{GDL}+\lambda_2 L_{LIP},
\]
produced only slight changes in image-domain attenuation metrics relative to a pure image loss, but it reduced projection-domain errors and improved downstream PET attenuation-corrected image accuracy [1909.01394].

Electromagnetic inverse scattering motivates losses built from near-field quantities inside the domain of interest. The paper compares the baseline contrast loss
\[
L^{\text{contrast}}(\hat{\chi})=\|\hat{\chi}-\chi\|_2^2
\]
with two physics-guided alternatives:
\[
L^{\text{current}}(\hat{\chi})=\frac12\|\mathbf J-\mathbf E^\text{tot}_{\text{DOI}}\odot \hat{\chi}\|_2^2+\beta\|\chi-\hat{\chi}\|_2^2,
\]
and
\[
L^{\text{field}}(\hat{\chi})=\frac12\|\mathbf E^\text{sca}_{\text{DOI}}-\mathbf G_{\text{DOI}}\hat{\chi}\|_2^2+\beta\|\chi-\hat{\chi}\|_2^2.
\]
These losses inject multiple-scattering-based near-field priors into training rather than supervising only the final contrast image [2111.09109].

Region-aware weighting is another recurring design. For a DeepONet surrogate of rarefied micro-step flow, the vortex region is defined by \(U(x,y)<0\), and the total loss is
\[
\mathcal L_{\text{total}}
=
\alpha\,\mathcal L_{\text{vortex}}+(1-\alpha)\,\mathcal L_{\text{main}},
\]
where each regional loss is normalized by the number of points in that zone. In the reported ablation, the full-domain relative \(L_2\) error changed only marginally, whereas the vortex-region relative \(L_2\) error improved substantially, which the authors interpret as better engineering fidelity of the recirculation structure [2509.17254].

## 5. Energetic, invariant, and interaction-based constructions

Not all physically meaningful objectives are formulated at the level of field equations. In mechanics, one can train a one-step predictor of pendulum states with mean-squared error plus an additional term measuring the energy difference between the input and predicted output state. The paper reports that the MSE-only model drifts toward lower-energy trajectories under rollout, whereas the energy-augmented loss preserves the phase-space orbit much better over four periods [2105.00075].

In power electronics, the supervisory signal may be latent. “Data-driven Power Loss Identification through Physics-Based Thermal Model Backpropagation” does not train against direct power-loss labels; instead, it embeds a reduced-order thermal model into the computation graph and optimizes
\[
\mathcal L_\omega
=
\mathrm{MSE}(y,\hat y_\omega)
+
\alpha\,\ell(u_\omega)
+
\beta\|\varepsilon_{u,\omega}\|_2,
\]
where the first term compares measured and predicted temperatures, \(\ell(u_\omega)\) penalizes negative corrected power losses, and \(\|\varepsilon_{u,\omega}\|_2\) regularizes deviation from the nominal power-loss model. The reported reduction in temperature and loss errors illustrates a form of indirect physical supervision through a differentiable thermal model [2504.00133].

“Molecular Learning Dynamics” takes an even stronger stance: the loss is not an auxiliary penalty but the scalar quantity whose gradient defines the particle dynamics. Each atom type uses a learned quadratic loss
\[
H_{\mathcal A_k}(\varphi)
=
A^{\mathcal A_k a}_m \varphi_a^m
+
\frac12 B_{mn}^{\mathcal A_k ab}\varphi_a^m\varphi_b^n,
\]
built from invariant descriptors of the surrounding environment. The induced equation of motion is \(M_{\mathcal A_k}\ddot q=-\nabla H_{\mathcal A_k}\), which generalizes the role of a global interaction energy to type-specific effective losses over invariant features [2504.10560].

The energy-loss framework for equilibrium systems makes symmetry an intrinsic property of the objective. Because the atomistic loss depends only on pairwise distances, its minimizers are symmetry-equivalent configurations rather than a single coordinate embedding, and the paper argues that this yields gradients better aligned with valid physical configurations than coordinatewise MSE. The same paper extends the reverse-KL/Boltzmann derivation to discrete systems through a free-energy objective and instantiates it for spin systems with a local-field energy [2511.02087].

Segmentation offers a different interaction-based construction. In “A Physics-Informed Loss Function for Boundary-Consistent and Robust Artery Segmentation in DSA Sequences,” the predicted and true boundaries are treated as interacting elastic curves through the nonlocal energy
\[
\mathcal{L}_{\text{EI}}
=
\frac{1}{8\pi}
\int_{\Omega}\int_{\Omega}
\frac{
\nabla (G_t + \alpha H(\phi))(\mathbf{x}) \cdot \nabla (G_t + \alpha H(\phi))(\mathbf{x}')
}{
\|\mathbf{x}-\mathbf{x}'\|
}
\,d\mathbf{x}\,d\mathbf{x}'.
\]
Here the physics is not hemodynamics but an elastic analogy inspired by dislocation theory in materials physics; the goal is smooth contour evolution and structural consistency of thin vessel boundaries [2511.20501].

Wave forecasting introduces yet another pattern. The MI2A framework decomposes physical-space MSE into dissipation and dispersion components:
\[
\tau_{\mathrm{DISS}}
=
\left[\sigma(\bar Y^j)-\sigma(X'^j)\right]^2
+
\left(\langle \bar Y^j\rangle-\langle X'^j\rangle\right)^2,
\]
\[
\tau_{\mathrm{DISP}}
=
2(1-\rho)\sigma(\bar Y^j)\sigma(X'^j),
\]
and trains with
\[
\mathcal L_{\mathrm{evolver}}
=
\psi\,\tau_{\mathrm{DISP}}
+
(1-\psi)\tau_{\mathrm{DISS}}.
\]
The decomposition is motivated by the classical dissipation-versus-dispersion taxonomy of numerical wave propagation, so the loss is physics-based without being a PDE residual [2504.11433].

## 6. Optimization geometry, conditioning, and open questions

Loss design affects not only what is being penalized but also the geometry seen by optimization. In visualized loss landscapes of physics-informed neural networks, both Deep Ritz and squared strong-form losses exhibited monotonic linear interpolation from initialization in the one-dimensional elliptic case, smooth convex basins near trained solutions, mode connectivity between solutions, highly singular Hessians with many near-zero eigenvalues, and low-dimensional optimizer trajectories. Around trained states, both formulations appeared “smooth, well-conditioned, and convex in the vicinity of the solution,” and in the two-dimensional hyperelastic example their gradient directions agreed “to a large extent.” The same study also found that Monte Carlo integration can differentiate the two substantially: in 1D the Deep Ritz integrand had variance five orders of magnitude larger than the strong-form integrand at the solution, so stochastic estimates of the Deep Ritz objective became much noisier even though deterministic quadrature landscapes were similar [2602.05849].

These observations complicate several common intuitions. One line of work shows that residual scaling induced by characteristic lengths, times, and coefficients can distort multi-objective optimization and shift the apparent Pareto front, making nominally identical loss weights behave very differently across parameterizations [2105.00862]. Another shows that the default \(L^2\) residual can be theoretically unsuitable for high-dimensional nonlinear HJB equations, whereas \(L^\infty\)-type control is more stable [2206.02016]. A plausible implication is that there is no universally “correct” physics-based loss independent of the PDE class, coefficient scales, sampling rule, or approximation regime.

The literature also cautions against overgeneralization. The benign PINN landscapes reported for Deep Ritz and strong-form losses were obtained with boundary conditions enforced exactly through multiplicative trial functions and with objectives containing only interior physics terms, so those findings were explicitly not generalized to all PINN losses with boundary penalties [2602.05849]. Likewise, some methods are physics-guided rather than physics-constrained: DeepONet zonal loss prioritizes a physically important region, but it does not enforce conservation laws; DPC embeds approximate SDE physics in the model while retaining a statistical CMMD objective [2509.17254], [2209.09750].

Current directions therefore span both hand-designed and learned objectives. Meta-learning for parametric PDEs replaces the standard data loss by a task-specific GAM-based loss while retaining the PDE residual, suggesting that even the loss itself can become an adaptable object rather than a fixed functional form [2412.00225]. Taken together, these works suggest that physics-based loss functions are best viewed not as a single recipe but as a design space in which governing laws, invariants, acquisition operators, utility metrics, and optimization geometry are coupled.

Source: https://www.emergentmind.com/topics/physics-based-loss-function