Physics-informed neural networks and their failure modes
Before this lesson: reverse-mode automatic differentiation (lesson 01); how a time stepper moves information forward (lesson 02); the spectral Burgers solver (lesson 08); MLPs and their training (deep learning 01, deep learning 02). Helpful: the condition number (optimization 02). Time: about 90 minutes, plus the notebook.
Why this matters #
- A popular method. PINNs (Raissi, Perdikaris and Karniadakis, 2019) appear in thousands of papers on fluids, heat transfer, geophysics and biology. Knowing when they work saves months of effort.
- Known failures. Plain PINNs fail on simple transport problems (Krishnapriyan et al., NeurIPS 2021). A systematic review of ML for fluid-related PDEs found that 79% (60 of 76) of the papers that claim to beat a standard numerical method compare against a weak baseline (McGreivy and Hakim, Nature Machine Intelligence, 2024).
- Physics penalties everywhere. The same issues (balancing loss terms, conditioning, causality in time) appear in every loss with a physics term, for example a mass-conservation penalty added to the loss of a weather emulator, or a residual term added to a neural operator.
- Inverse problems. With sparse, noisy data and a known PDE, the PINN loss is a regularised inverse problem, close to weak-constraint 4D-Var (lesson 06).
1. Predict first #
2. The picture #
A PINN in one formula #
Choose a network with parameters . Pick collocation points inside the space-time domain, points at , and points on the boundary. Minimise
where is the initial condition, are weights, and is a squared boundary mismatch. For advection the residual is . The derivatives of the network with respect to its inputs come from automatic differentiation. The network is one function of all space and time at once. Observations, if you have any, add one more squared-error term.
The simplest case: one Fourier mode #
Try . Then
so the PDE becomes the harmonic oscillator , with , . Its solution , gives . So the PINN must learn a function that oscillates times in on : 0.16 times at , 4.8 times at .
A solver marches; a PINN does not #
A time stepper (lesson 02) computes from . Information flows forward from the initial condition, as in the physics. A PINN fits all of space-time at once. The residual at only links values of at nearby points, and a field that knows nothing about the initial condition (a constant, for example) makes it zero. The initial condition reaches late times only through the optimiser, step by step.
Move from 1 to 30. Four candidate fields for advection with : the exact solution, the frozen initial condition , the zero field and a slower wave . The table gives the residual loss , the weighted initial-condition loss , the total and the relative error; the bars show on a log scale. The frozen field costs , while the zero field always costs . The magenta marker shows the wrong field with the lowest loss: the one an optimiser is pulled towards. Then raise and watch which wrong field wins.
What goes wrong at large . Three things happen together.
- Imbalance: is 30 times larger at , so the residual term is about times larger and dominates the gradient. The initial-condition term, which says which solution we want, gets a small share.
- Spectral bias: tanh networks fit smooth, low-frequency functions first, and the solution oscillates fast in .
- No causality: nothing makes early times converge before late times.
The typical result: the PINN fits the initial condition near , but after a short time it no longer follows the travelling wave (Krishnapriyan et al., Fig. 1). The network is big enough: a better training procedure makes the same network solve the problem (section 3).
Advection with , , . What is the PINN loss of the frozen field (means over the whole domain)?
Its residual is , and the mean of over is . The initial-condition term is zero. The zero field has , so it is 900 times "better" in the loss, although its error is 100%.
3. Definitions and main results #
The PINN problem #
Take a PDE for in a domain and , with initial condition and a boundary condition. Examples: advection, ; viscous Burgers, with viscosity . The residual of a candidate is , and the PINN loss is the formula of section 2.
Nested automatic differentiation. The network output is a scalar, so one reverse sweep
gives both and at a point (lesson 01). The second derivative needs a second sweep,
through the computation of . Training needs : a third sweep through everything.
So the inner sweeps must be recorded as computations themselves (create_graph=True in PyTorch), and memory
grows with each level. The activation must also be smooth: a ReLU network is piecewise linear, so
almost everywhere, and it cannot see a viscous term.
Theorem 1: for advection, a small residual gives a small error #
Let solve on with periodic boundary conditions. Let be smooth and periodic, with residual and error . With the norm over ,
Why this is true, in words. Advection only moves the error around; it never makes it larger. So the error can grow only through the residual, which acts as a source term, and at most by the size of that source.
Proof of Theorem 1
- The PDE is linear and has zero residual, so .
- Multiply by and integrate over : .
- , and the integral of the derivative of a periodic function is zero. With Cauchy–Schwarz: .
- Where , the left side equals , so . (To include times where , apply step 3 to and let .)
- Integrate from to .
Three consequences:
- For advection, a small loss does mean a small error. So when a PINN for advection is wrong, its loss is not small: the optimiser did not find the small loss that exists. The failure is an optimisation failure. Krishnapriyan et al. reach the same conclusion from experiments.
- The bound says how small "small" must be. If the initial condition is exact and at all times, the relative error at is at most , with for . A 1% guarantee needs , that is, a mean squared residual .
- For a nonlinear PDE the same steps give a Grönwall factor (next box). For a chaotic system errors grow like with the largest Lyapunov exponent (lesson 05), so the residual controls late times only weakly.
The nonlinear case: a Grönwall factor
If at all times, the same steps give
For periodic viscous Burgers, works, with the true solution: the term cubic in integrates to zero, and the viscous term only helps. is large near a steep front, so the same residual allows a larger error there. This is the idea behind the PINN error estimates of Mishra and Molinaro (2023).
A plain PINN for advection at ends with a relative error near 90%. A colleague proposes a network 4 times wider. What does Theorem 1, together with the experiments of Krishnapriyan et al., suggest?
For advection a small residual guarantees a small error, so a large error means a large loss: the training stopped in a bad region. Curriculum training of the same network reaches about 2% error at (Krishnapriyan et al., Table 1). Multiplying the residual weight by makes the imbalance worse, not better.
Why training fails: three views #
(a) The difficulty is in the coordinates, not in the physics. Write , the solution seen by an observer who moves with speed . Then . The map preserves area on the periodic domain, so, with means over the domain in place of the sums,
This does not depend on : in the moving frame the solution is , constant in , for every . So only changes how hard the solution is to represent and optimise in the coordinates that the network sees. On a grid with points in , the operator has a condition number of about , and the squared loss squares it to about (Krishnapriyan et al., App. B, a rough estimate). For Burgers the characteristics depend on the unknown solution, so this change of frame is not available.
(b) Imbalance and spectral bias: the neural tangent kernel view. For a wide network trained with small steps, the outputs change almost linearly in the parameters. Let be the matrix with rows and the matrix with rows . The neural tangent kernel (NTK) blocks are , and . For the loss , gradient flow in the training time gives
When the kernel stays almost constant, an error component along an eigenvector with eigenvalue decays like (Wang, Yu and Perdikaris, 2022, analyse PINNs this way). Two facts matter here.
- contains , so grows like for large , while does not depend on . The residual is driven down fast and the initial condition slowly. For a random one-hidden-layer tanh network with 256 units, is 0.64, 16 and 149 at (code in section 5).
- The large eigenvalues of the kernel belong to smooth functions. This is spectral bias (Rahaman et al., 2019): gradient descent fits the low-frequency part of a target first. For the same kind of network, the initial fitting speed of is about 300 times smaller than that of .
Together: the network quickly reaches fields with a small residual that ignore the initial condition (for example nearly flat ones), and it leaves them only slowly.
Choose , then , and move the step slider. A random one-hidden-layer tanh network is trained, in its linearised (NTK) form, to fit the target ; the fit after gradient steps is shown on top. The bottom panel gives the relative error against for five values of (same network, same learning rate). is fitted in about ten steps; still has a large error after a million steps. The low frequencies of the target are fitted first.
(c) No causality. Wang, Sankaran and Perdikaris (2024) measured the residual separately at each time during training. A plain PINN often reduces the residual at late times as fast as, or faster than, at early times. But the correct late-time field depends on the correct early-time field, so this is the wrong order.
The fixes #
1. Curriculum training (Krishnapriyan et al., §5.1). Train at a small , use the weights to start the training at a larger , and continue in steps up to the target (for example ). Each stage starts near a good solution of the next problem. Relative errors in their Table 1, plain → curriculum: : 0.750 → ; : 0.897 → ; : 0.961 → . Same network, so its size was never the problem.
2. Time marching (sequence-to-sequence) (§5.2). Split into windows of length . Train a PINN on the first window; its prediction at the end of the window is the initial condition of the next window. This is a time stepper whose "step" is a training run: it respects causality, but costs one training per window, and errors pass from window to window. For convection at (their Table E.1) the error falls from 0.738 to 0.105 with .
3. Causal weighting (Wang, Sankaran and Perdikaris). Split the time interval into ordered chunks , and let be the mean squared residual of the collocation points in chunk . Replace by
Chunk gets a large weight only after all earlier chunks have small residuals. The weights are computed
from the current losses but treated as constants: no gradient flows through (stop_gradient in JAX,
.detach() in PyTorch). The causality parameter sets how strict this is: too small and
nothing is enforced, too large and the late chunks never switch on. The paper increases through
and moves to the next value when , a useful convergence check.
Press Play, or step through training. A small network (one hidden layer of 64 tanh units) learns advection at in the one-mode form ; the run was computed in NumPy with Adam. Top: the learned and the exact coefficient . Middle: the residual at each of 32 times (log scale). Bottom: the causal weights with . The weights switch on from left to right, and the learned curve follows the exact one from forward. After 20,000 steps the causal run has an RMS error of 0.045 against 0.068 for the plain run. Switch to "plain": all weights are 1.
Four time chunks have residuals and . What is the causal weight of chunk 4?
. Only the earlier chunks enter, never the chunk itself. Chunk 3's large residual switches chunk 4 off until chunk 3 is solved; is the weight of chunk 3.
Supporting tricks (Wang et al., An Expert's Guide to Training PINNs, 2023):
- Exact periodic boundary conditions: feed instead of . Every function of these inputs is exactly -periodic, so disappears (Dong and Ni, 2021).
- Fourier features: map the inputs to with a random matrix , against spectral bias (Tancik et al., 2020).
- Loss balancing: every 100–1,000 steps set for each loss term and update by a moving average, so all weighted terms have the same gradient norm.
- Scaling and optimiser: non-dimensionalise; use Adam, often followed by L-BFGS (optimization 10).
With these tricks plus causal weighting, the guide reaches a relative error of for advection at speed 80 (§7.2); its ablations show that each part matters.
Burgers: steep fronts #
The residual is nonlinear and of second order. For small the solution forms a steep front. The steady front , with the half-height of the jump, is an exact solution. It goes through 90% of its jump over a width of : 0.019 for the classic PINN test case , on . The network must represent this steep feature (spectral bias again), and the collocation points must resolve it: uniform random points put only about 1% of the points there. Residual-based adaptive sampling adds points where is large (Lu et al., DeepXDE, 2021). As the front becomes a shock where the residual is not defined.
PINN or solver? #
For a forward problem with a known PDE on a simple domain, a classical solver wins. The pseudo-spectral Burgers solver of lesson 08 matches the exact Cole–Hopf solution to (, 128 grid points) in a fraction of a second on a laptop. For advection, the Fourier solver is exact up to round-off. The tuned PINN of the Expert's Guide reaches on 1-D advection after 200,000 Adam steps on a GPU. And a PINN solves one initial condition per training run, while a solver or a neural operator handles any new one.
Compare , and . Space-time images ( across, up) of the exact solution and of two PINN fits. The PINN here is a random-feature network (200 fixed tanh features of ) whose output weights minimise the PINN loss exactly by linear least squares, so no optimiser can be blamed. One window over works at and fails at (error 98%): these features hold mostly slow variations in . Ten windows of length 0.1 (time marching) give 0.16%. The Fourier solver of lesson 08 gives round-off error.
A PINN is a sensible choice when the problem is not a clean forward problem:
- inverse problems: unknown coefficients (, , a diffusivity field) or sources, estimated together with from sparse, noisy observations; the PDE acts as a regulariser (lesson 04);
- data together with a partly known PDE, an irregular domain, or no solver at hand;
- the residual as an extra loss on a neural operator (physics-informed neural operators).
The data-plus-residual loss is weak-constraint 4D-Var (lesson 06) in another form: a data misfit plus a penalty on model error. The weight of the residual term plays the role of the inverse model-error covariance , and the network replaces the model trajectory.
In which situation is a PINN the most sensible choice?
The first is a clean forward problem: a spectral solver is more accurate and much cheaper. The second calls for a solver or a neural operator, because a PINN needs one training run per instance. For chaos, a small residual does not control late-time errors. An inverse problem with sparse data uses the PDE as a regulariser, which is where the PINN loss helps.
Answers to section 1. (1) It fails. In Krishnapriyan et al. the relative error is close to 100% for (0.750 at , 0.897 at ; at it is still ). The network is not too small: curriculum training of the same network reaches . (2) The zero field. With its loss is (the mean of ). The frozen initial condition has residual , so . At both losses are . A large makes "keep the initial condition" very expensive and "flatten everything" cheap.
4. Worked example #
(a) Three candidates at (; means over the domain). The relative error is taken over the whole space-time domain.
| candidate | relative error | ||
|---|---|---|---|
| exact, | 0 | 0 | 0 |
| zero | 0 | 0.5 | 1 |
| frozen, | 0 | 1.44 |
For the frozen candidate, step by step:
- The mean over of is (expand the square; the cross term has mean ).
- Its mean over is .
- Divide by the mean of , which is , and take the square root: .
At the same candidate has and relative error .
(b) Theorem 1 on a wrong-speed candidate. Take while .
- Its residual is , so and at every .
- The initial error is zero, so the bound gives : a relative error of at most .
- The true error: , so the relative error is . At it is .
A mean squared residual of allows almost 100% error; for 1% you need (section 3).
(c) Causal weights by hand. Four chunks have residuals ; the plain mean is 0.630. The sums of the earlier chunks are , so :
- : : a mild effect; the last chunk still trains.
- : : chunk 4 is switched off until chunk 3 is solved.
- : : even chunk 3 is nearly off.
The causal losses are , and : a larger hides more of the late residual.
For , a PINN reports a mean squared residual at all times and an exact initial condition. What relative error at does Theorem 1 guarantee?
, and the bound is . Divided by this is . The bound does not depend on . Taking or itself as the error ignores the norms.
5. In code #
PyTorch is the usual tool for PINNs. The first block computes residuals by automatic differentiation with respect to the inputs, for closed-form candidates and for a network:
import math
import torch
torch.set_default_dtype(torch.float64)
def advection_residual(u_fn, x, t, beta):
"""r = u_t + beta u_x at the points (x, t), by reverse-mode AD with respect to the inputs."""
x, t = x.detach().requires_grad_(True), t.detach().requires_grad_(True)
u = u_fn(x, t)
u_x, u_t = torch.autograd.grad(u, (x, t), torch.ones_like(u), create_graph=True)
return u_t + beta * u_x
# a uniform space-time grid on [0, 2π) x [0, 1]
X, T = torch.meshgrid(torch.arange(64) * 2 * math.pi / 64, torch.linspace(0, 1, 51), indexing="ij")
x, t, beta = X.ravel(), T.ravel(), 30.0
candidates = {
"exact sin(x - βt)": lambda x, t: torch.sin(x - beta * t),
"frozen sin(x) ": lambda x, t: torch.sin(x) + 0 * t,
"zero ": lambda x, t: 0 * x + 0 * t,
}
for name, fn in candidates.items():
L_r = advection_residual(fn, x, t, beta).pow(2).mean().item()
L_ic = (fn(x[t == 0], t[t == 0]) - torch.sin(x[t == 0])).pow(2).mean().item()
print(name, f"L_r = {L_r:.3g} L_ic = {L_ic:.3g}")
# exact sin(x - βt) L_r = 0 L_ic = 0
# frozen sin(x) L_r = 450 L_ic = 0
# zero L_r = 0 L_ic = 0.5
def burgers_residual(u_fn, x, t, nu):
"""r = u_t + u u_x - nu u_xx. The second derivative needs a second backward pass."""
x, t = x.detach().requires_grad_(True), t.detach().requires_grad_(True)
u = u_fn(x, t)
u_x, u_t = torch.autograd.grad(u, (x, t), torch.ones_like(u), create_graph=True)
u_xx = torch.autograd.grad(u_x, x, torch.ones_like(u_x), create_graph=True)[0]
return u_t + u * u_x - nu * u_xx
nu = 0.01 / math.pi
front = lambda x, t: -torch.tanh(x / (2 * nu)) + 0 * t # steady viscous front, U = 1
xs = torch.linspace(-1, 1, 201)
print(f"{burgers_residual(front, xs, torch.zeros(201), nu).abs().max().item():.0e}") # 4e-15
torch.manual_seed(0)
net = torch.nn.Sequential(torch.nn.Linear(2, 32), torch.nn.Tanh(), torch.nn.Linear(32, 1))
u_net = lambda x, t: net(torch.stack([x, t], dim=-1)).squeeze(-1)
x0, t0, h = torch.tensor([0.3]), torch.tensor([0.4]), 1e-4
r_ad = burgers_residual(u_net, x0, t0, nu)
with torch.no_grad(): # the same residual by central differences
u = lambda dx, dt: u_net(x0 + dx, t0 + dt)
r_fd = ((u(0, h) - u(0, -h)) / (2 * h) + u(0, 0) * (u(h, 0) - u(-h, 0)) / (2 * h)
- nu * (u(h, 0) - 2 * u(0, 0) + u(-h, 0)) / h**2)
print(f"{abs(r_ad - r_fd).item():.1e}") # 2.2e-10: AD agrees with finite differences
r_ad.pow(2).sum().backward()
print(all(p.grad is not None for p in net.parameters())) # True: gradients reach every weight
Second, Theorem 1 on the wrong-speed candidate of worked example (b), at three times (NumPy):
import numpy as np
x = np.linspace(0, 2 * np.pi, 1024, endpoint=False)
norm = lambda f: np.sqrt(np.sum(f**2) * (2 * np.pi / len(x))) # L2 norm over [0, 2π)
u_norm = norm(np.sin(x)) # sqrt(π) = 1.7725
s = np.linspace(0, 1, 2001)
r_norm = np.array([norm((30 - 29) * np.cos(x - 29 * si)) for si in s]) # ‖r(·, s)‖ = sqrt(π)
for T in [0.25, 0.5, 1.0]:
err = norm(np.sin(x - 29 * T) - np.sin(x - 30 * T))
bound = np.trapezoid(r_norm[s <= T], s[s <= T])
print(T, f"{err / u_norm:.3f} <= {bound / u_norm:.3f}")
# 0.25 0.249 <= 0.250
# 0.5 0.495 <= 0.500
# 1.0 0.959 <= 1.000
Third, the two NTK facts of view (b), for a one-hidden-layer tanh network whose Jacobians we can write by hand: spectral bias for a plain regression, and the growth of the residual block at initialisation:
rng = np.random.default_rng(0)
H = 256 # hidden units; f = sum_j a_j tanh(w_j z + b_j) / sqrt(H)
def jac_1d(t, w, b, a):
"""Rows d f(t_i) / d(a, w, b) for a one-hidden-layer tanh network of one input."""
th = np.tanh(np.outer(t, w) + b); s2 = 1 - th**2
return np.hstack([th, a * s2 * t[:, None], a * s2]) / np.sqrt(H)
# (1) Spectral bias: the NTK fits cos(βt) more slowly as β grows.
w, b, a = 4 * rng.normal(size=H), rng.normal(size=H), rng.normal(size=H)
t = np.linspace(0, 1, 200)
J = jac_1d(t, w, b, a)
Theta = J @ J.T # the NTK on 200 points
lam_max = np.linalg.eigvalsh(Theta)[-1]
for beta in [1, 5, 10, 30]:
y = np.cos(beta * t)
print(beta, f"{(y @ Theta @ y) / (y @ y) / lam_max:.1e}") # initial fitting speed, relative
# 1 9.4e-01 5 2.3e-01 10 2.0e-02 30 3.1e-03
# (2) Imbalance: the residual block of the kernel grows like β² against the initial-condition block.
w1, w2, b2, a2 = (rng.normal(size=H) for _ in range(4))
def rows_u(x, t): # d u / d(a, w1, w2, b) for u(x, t)
th = np.tanh(np.outer(x, w1) + np.outer(t, w2) + b2); s2 = 1 - th**2
return np.hstack([th, a2 * s2 * x[:, None], a2 * s2 * t[:, None], a2 * s2]) / np.sqrt(H)
def rows_r(x, t, beta): # d r / d(a, w1, w2, b) for r = u_t + beta u_x
th = np.tanh(np.outer(x, w1) + np.outer(t, w2) + b2); s2 = 1 - th**2
m, ds2 = w2 + beta * w1, -2 * th * s2 # r = sum_j a_j s2_j m_j / sqrt(H)
return np.hstack([s2 * m, a2 * (ds2 * x[:, None] * m + beta * s2),
a2 * (ds2 * t[:, None] * m + s2), a2 * ds2 * m]) / np.sqrt(H)
xr, tr, x0 = 2 * np.pi * rng.random(300), rng.random(300), 2 * np.pi * rng.random(300)
J_ic = rows_u(x0, np.zeros(300))
for beta in [1.0, 10.0, 30.0]:
J_r = rows_r(xr, tr, beta)
print(beta, f"{(J_r**2).sum() / (J_ic**2).sum():.3g}") # tr K_rr / tr K_uu
# 1.0 0.638 10.0 16.3 30.0 149
The ratio is the initial rate at which kernel gradient descent reduces the error , relative to the fastest direction: about 300 times smaller for than for . Both kernel blocks of the second part use 300 points, so the trace ratio compares the two loss terms fairly.
6. Where it shows up #
- Seismology. EikoNet (Smith, Azizzadenesheli and Ross, IEEE Transactions on Geoscience and Remote Sensing, 2021) trains a network on the residual of the eikonal equation for first-arrival travel times in a 3-D velocity model , and uses it for earthquake location and tomography. This is an inverse setting with a cheap residual, where a mesh-free representation helps.
- Weather and climate. As of 2026, the main ML weather models (GraphCast, ECMWF's AIFS) are trained on reanalysis data, and NeuralGCM trains through a differentiable dynamical core: none of them minimises a PDE residual (lesson 16). Residual losses appear as extra terms (physics-informed neural operators, conservation penalties), and a PINN with observation terms is a weak-constraint 4D-Var.
- Machine learning. The same spectral-bias analysis explains why coordinate networks (NeRF) use Fourier features. DeepXDE and jaxpi are widely used PINN libraries.
- Benchmarks. A fair benchmark compares with a tuned classical solver at equal accuracy or equal cost, and reports the error against a reference solution, not the training loss.
7. Common mistakes #
- Reporting the loss instead of the error. Compare with a reference solution; Theorem 1 shows how small the residual must be, and for chaotic PDEs even that is not enough.
- No
create_graph=Truefor the input derivatives. The residual term then has no gradient. If the initial-condition term still trains, nothing crashes, but the PDE has no effect. - ReLU for a PDE with second derivatives. almost everywhere, so the viscous term disappears. Use tanh, GELU, sine or another smooth activation.
- Unbalanced loss terms, soft periodic conditions when the exact inputs are available, and inputs on very different scales ( in km, in s).
- Too few or fixed collocation points for a steep front. Resample every step, or add points where the residual is large.
- Gradients through the causal weights, or unsorted time chunks. The weights must be constants.
- A weak baseline (a coarse or untuned solver), and expecting generalisation: a PINN solves one problem instance; a new initial condition needs a new training run.
8. Check yourself #
- Write the PINN loss for viscous Burgers on with periodic boundary conditions and initial
condition . Which derivatives does each collocation point need, and how are they computed?
Answer
with . Periodicity either by a penalty on (and on ), or exactly with the inputs . Each point needs and (one reverse sweep, because the output is a scalar) and (a reverse sweep through the computation of ). Training differentiates all of this with respect to , so the inner sweeps are recorded (`create_graph=True`). - For advection with on , the residual norm is about the
same at all times and the initial condition is exact. What mean squared residual is enough for a relative
error below 1% at ?
Answer
By Theorem 1, with . A relative error below 1% needs . The mean squared residual is . The answer does not depend on . - Three time chunks have residuals and . Compute the causal weights and the
causal residual loss.
Answer
Earlier sums , so . The loss is , against the plain mean . - Why is the moving-frame argument of view (a) not a general fix, and what does it show?
Answer
For linear advection with a known the moving frame solves the problem exactly, so there is nothing to learn. For Burgers the characteristics depend on the unknown solution, so you cannot change coordinates in advance. It shows that the PINN loss for advection is equally well posed for every ; what gets harder is representing and optimising the solution in the coordinates . - A colleague's Burgers PINN uses ReLU and gives a smooth but wrong solution with a low loss. What happened?
Answer
A ReLU network is piecewise linear in , so almost everywhere (and autograd returns 0 at the kinks). The residual the network sees is : it trains on the inviscid equation, and the viscous term has no influence on the result. - When would you prefer a PINN to the spectral solver of lesson 08 for Burgers?
Answer
When it is not a clean forward problem: for example (or a forcing) is unknown and you have only sparse, noisy observations of . The PINN then fits and together, with the residual as a regulariser. For the forward periodic problem the solver is far more accurate () and far cheaper.
Write the PINN loss for with initial condition .
(+ boundary terms), with .
How is of a network computed for a PINN residual?
By a second reverse sweep through the recorded computation of (nested AD,
create_graph=True); training then differentiates that again with respect to .State Theorem 1 (advection, periodic) of this lesson.
: the error is bounded by the initial error plus the integrated residual norm.
Advection at , : what is of the frozen field ?
(the residual is ).
Why does a large cause loss imbalance?
The residual contains , so the residual term and its kernel block grow like , while the initial-condition term does not change.
What is spectral bias?
Gradient descent on a neural network fits the low-frequency part of a target first; high frequencies converge much more slowly (large NTK eigenvalues belong to smooth functions).
Give the causal weight of time chunk .
, computed from the current losses and treated as a constant (no gradient).
Name three fixes for the PINN failure on fast advection.
Curriculum training in , time marching over short windows, and causal weighting.
When does a PINN make sense instead of a classical solver?
For inverse problems with sparse, noisy data and a known PDE (unknown coefficients or sources), or with irregular geometry and no solver at hand.
9. Interview angle #
- "Why do PINNs fail on advection at high speed? Is the network too small?" — No: curriculum training of the same network works. A residual term that grows like , spectral bias and no causality in time make the optimisation hard.
- "How would you fix it?" — Curriculum in , time marching, causal weights; exact periodic inputs, Fourier features, gradient-norm loss balancing, non-dimensionalisation, L-BFGS at the end.
- "Your PINN loss is . Is the solution accurate?" — Only through a stability estimate (Theorem 1 for advection, a Grönwall factor for nonlinear PDEs, nothing useful for chaos). Check against a reference solution.
- "PINN, neural operator or solver?" — Solver for forward problems; neural operator for many instances with training data; PINN for inverse problems with sparse data and a known PDE.
- "How do PINNs relate to data assimilation?" — Data misfit plus residual penalty is weak-constraint 4D-Var, with the network as the space-time trajectory.
10. Practice #
The notebook for this lesson runs in Colab or in the browser. It uses only NumPy (no deep-learning library) and has five exercises, each with a check cell and a folded solution:
- PINN losses of candidate fields on a grid (exact, frozen, zero), from their derivatives.
- Check the bound of Theorem 1 for a wrong-speed and a damped candidate.
- Spectral bias: fit with a linear model on random tanh features by gradient descent and compare with .
- A random-feature PINN for advection, solved by linear least squares: failure at and the time-marching fix.
- The Fourier solver of lesson 08 for the same problem: error and cost against the PINN.
11. Watch and read #
- Krishnapriyan et al., Characterizing possible failure modes in physics-informed neural networks (NeurIPS 2021): §3.1 (the convection failure), §4 (loss landscapes), §5.1 (curriculum, Table 1), §5.2 (sequence-to-sequence learning), App. B (the condition-number estimate).
- Wang, Sankaran and Perdikaris, Respecting causality for training physics-informed neural networks (CMAME 2024): §2 (the causality violation), §3 (causal weights and the choice of ).
- Wang et al., An Expert's Guide to Training Physics-informed Neural Networks (2023): §3 (non-dimensionalisation), §4.2 (Fourier features), §5 (causality, loss balancing, curriculum), §7.2 (advection); code in jaxpi.
- Wang, Yu and Perdikaris, When and why PINNs fail to train: a neural tangent kernel perspective (J. Comput. Phys., 2022).
- Rahaman et al., On the Spectral Bias of Neural Networks (ICML 2019); Tancik et al., Fourier Features Let Networks Learn High Frequency Functions (NeurIPS 2020).
- Raissi, Perdikaris and Karniadakis, Physics Informed Deep Learning (Part I), the preprint of the 2019 J. Comput. Phys. PINN paper.
- McGreivy and Hakim, Weak baselines and reporting biases lead to overoptimism in machine learning for fluid-related PDEs (Nature Machine Intelligence, 2024).
- Thuerey et al., Physics-based Deep Learning (free online book), part "Physical Losses": physical loss terms and a Burgers PINN.
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.