Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Checking the equation where it matters
A PINN checks its equation only at the points we choose. If the answer has a steep jump somewhere and few points land there, the network can ignore the jump. A simple fix is to look at where the equation is most badly broken and add points there; repeat a few times and the points gather where the hard part is. Problems that unfold in time have another trap. The network looks at all times at once and may fit the late times before the early times are right, like writing the end of a story before the beginning. Causal training makes it solve the start first. The demo shows points moving to a steep layer.
Simulations of shock waves around re-entering capsules and of flame fronts use the same idea in classical solvers: adaptive mesh refinement puts small cells only where the solution changes quickly.
- 1. Adaptive sampling adds collocation points where…
- 2. Causal training makes a time-dependent PINN…
- 3. A classical analogue of adaptive sampling is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Fixed sampling: uniform grids, random uniform points, or low-discrepancy sets (Latin hypercube, Sobol’, Halton). Resampling a fresh random set at every step acts like stochastic gradient descent on the integral of the squared residual.
- RAR (Lu et al., 2021): every few thousand steps, evaluate the residual on many candidate points and add the m with the largest residual.
- RAR-D and RAD (Wu et al., 2023): sample new points with density p(x) ∝ |r(x)|ᵏ / mean|r|ᵏ + c. The constant c keeps some points everywhere; k sharpens the focus. RAD resamples the whole set this way, RAR-D adds to it.
- Importance-sampling view: if points are drawn from p, the unbiased estimate of ∫ r² dx weights each point by 1/p (A5-2-6). Without the weights, adaptive points also reweight the loss toward hard regions, which is often intended.
- Causality in time (Wang, Sankaran and Perdikaris, 2024): split [0, T] into chunks with mean squared residuals L₁, …, L_M and weight chunk i by wᵢ = exp(−ε Σ_(k < i) L_k), treated as constants in the gradient. Training ends when the last weight is near 1.
- Related remedies: time-marching (train on [0, T/K], then extend), sequence-to-sequence training (Krishnapriyan et al., 2021) and curriculum regularisation.
- 1. RAR adds points…
- 2. In RAR-D, the constant c…
- 3. Causal weights are…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Causal weights for a time-dependent PINN
Exercise 1.
- An oscillator u″ + ω²u = 0 with u(0) = 1, u′(0) = 0 built into the ansatz u = 1 + s²N(s), s = t/T.
- Chunk losses and causal weights wᵢ = exp(−ε Σ_(k < i) L_k).
- Adam with and without causal weights, and Levenberg–Marquardt without them, over 1.5 periods.
Practice.
- Start with low-discrepancy or resampled random points; look at the residual map before choosing an adaptive scheme.
- Use RAR-D or RAD with c around 1 so smooth regions keep enough points; pure top-k selection can cluster points next to each other.
- Evaluate on a much finer set than you train on; a small training residual between sparse points means little.
- For long time horizons, use causal weights or time-marching; monitor the smallest causal weight as a convergence signal. Choose ε so that the weights rise gradually.
- Combine with a strong optimiser: L-BFGS or Levenberg–Marquardt often fixes what reweighting tries to fix.
- Tools: DeepXDE’s resampler callback and RAR examples, jaxpi’s causal training, PhysicsNeMo’s importance sampling.
import numpy as np
def rard(residual_fn, n_new, k=2.0, c=1.0, n_cand=10_000, rng=np.random.default_rng(0)):
cand = rng.uniform(0, 1, n_cand) # candidate points in the domain
e = np.abs(residual_fn(cand)) ** k
p = e / e.mean() + c
return rng.choice(cand, n_new, replace=False, p=p / p.sum())
# every few thousand steps: x_train = np.concatenate([x_train, rard(residual, 100)])- 1. Pure top-k selection of new points can…
- 2. A convergence signal for causal training is…
- 3. Evaluate a PINN on…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Sampling as an estimate of an integral. The ideal loss is ∫ r(x)² dx. Uniform points estimate it with error that depends on how r varies; a narrow layer where r is large is missed unless points fall there. Sampling from p(x) ∝ r² is the zero-variance importance distribution for this integral, which is why residual-based densities focus effort efficiently. Adding points without importance weights also changes the objective: hard regions count more, which helps when the network can use extra capacity there.
When adaptive sampling helps. A trainable network can move its features (here, steep tanh units) to the layer when the loss demands it. In Exercise 2 RAR put 41% of the final 40 points within 0.1 of the layer, against 20% for uniform points, and on two of three seeds turned a failed fit (error 0.3) into a good one (0.003–0.005). With a fixed set of features the same reweighting cannot add capacity and can worsen the fit elsewhere, so the benefit depends on the model.
Why causality matters. For u″ + ω²u = 0 every function a cos ωt + b sin ωt satisfies the equation locally. The initial conditions select one, but their information must propagate forward in time through the residual. A first-order optimiser that minimises the residual everywhere at once can settle on functions that are nearly zero or out of phase at late times. Causal weights make the late-time residual count only once early times fit, mimicking a time-stepping solver. Levenberg–Marquardt, which solves the linearised least-squares problem at each step, propagated the information without help in this small problem.
- 1. The zero-variance sampling density for ∫ r² dx is proportional to…
- 2. Adaptive sampling helps most when the model…
- 3. For u″ + ω²u = 0, the equation alone is satisfied by…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Do adaptive collocation points and causal weights improve PINN accuracy, and when?
History.
- L. Lu, X. Meng, Z. Mao and G. Karniadakis (2021) introduced residual-based adaptive refinement in DeepXDE.
- A. Krishnapriyan et al. (2021) showed PINNs failing on convection and reaction problems and proposed curriculum and sequence-to-sequence training.
- C. Wu, M. Zhu, Q. Tan, Y. Kartha and L. Lu (2023) compared ten sampling methods and proposed RAD and RAR-D.
- S. Wang, S. Sankaran and P. Perdikaris (2024), “Respecting causality for training physics-informed neural networks”, introduced causal weights and solved chaotic and turbulent benchmarks.
Exercise 1 (causality). u″ + (2π)²u = 0 on [0, 1.5] with u = 1 + s²N(s); width-30 tanh network, 120 points, 12 chunks, ε = 1; Adam 3000 steps with a decaying learning rate; median of 3 initialisations.
| method | relative error |
|---|---|
| Adam | 0.8 |
| Adam with causal weights | 0.08 |
| Levenberg–Marquardt, no weights | 0.00001 |
Exercise 2 (sampling). u″ = f on [0, 1] with exact solution arctan(50(x − 0.5)) and a hard boundary ansatz; width-24 tanh network trained by Levenberg–Marquardt; 40 points: uniform from the start, or 24 uniform plus 4 rounds of 4 adaptive points (80 steps per round). Median relative error of 5 initialisations, and the share of final points within 0.1 of the layer.
| points | error, seed 0 / 1 / 2 | share near the layer |
|---|---|---|
| uniform | 0.008 / 0.3 / 0.3 | 0.2 |
| RAR (largest local maxima) | 0.006 / 0.003 / 0.005 | 0.41 |
| RAR-D (k = 2, c = 1) | 0.01 / 0.006 / 0.01 | 0.34 |
- Adaptive points made training reliable. Uniform points sometimes worked (seed 0) and often failed (seeds 1 and 2); RAR succeeded on all three.
- RAR-D was a little less accurate but more spread out, keeping points in smooth regions.
- Causal weights rescued Adam, from an error of 0.8 to 0.08 on seed 0 (0.2 and 0.04 on seeds 1 and 2), but a second-order optimiser solved the same problem without them.
- Seeds 1 and 2 (causality): Adam 0.8 and 0.8; with causal weights 0.2 and 0.04; Levenberg–Marquardt 0.000002 and 0.00001.
Sampling and causality in applications
- Shock and boundary layers: compressible flow PINNs use residual-based sampling to resolve shocks, much like adaptive mesh refinement in classical CFD.
- Long-time dynamics: causal training and time-marching are standard for chaotic systems such as the Kuramoto–Sivashinsky equation and for long integrations in weather-like problems.
- Spacecraft and plasma: sharp fronts in re-entry heating and magnetic reconnection layers need points concentrated where gradients are steep.
- Data assimilation: sampling can also follow where measurements are dense, combining data and residual terms (J2-5).
References
- L. Lu, X. Meng, Z. Mao and G. E. Karniadakis (2021). “DeepXDE: a deep learning library for solving differential equations.” SIAM Review.
- C. Wu, M. Zhu, Q. Tan, Y. Kartha and L. Lu (2023). “A comprehensive study of non-adaptive and residual-based adaptive sampling for physics-informed neural networks.” Computer Methods in Applied Mechanics and Engineering.
- S. Wang, S. Sankaran and P. Perdikaris (2024). “Respecting causality for training physics-informed neural networks.” Computer Methods in Applied Mechanics and Engineering.
- A. Krishnapriyan et al. (2021). “Characterizing possible failure modes in physics-informed neural networks.” NeurIPS.