Tabular, time-series, scientific, and geometric deep learning · Molecular and scientific deep learning · SPE013 · Training method
Physics-informed neural network (PINN)
A PINN fits a neural function while penalizing differential-equation residuals and initial/boundary conditions, optionally alongside observations.
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
A PINN fits a neural function while penalizing differential-equation residuals and initial/boundary conditions, optionally alongside observations. It supports forward solution approximation and inverse parameter estimation when the physical model is sufficiently specified.
Question / hypotheses
The operative question is whether the specified representation, symmetry, likelihood or physical constraint improves held-out behavior for this data domain. This is a learning framework, not a null-hypothesis test; losses, attention weights and predictive confidence are not statistical p-values.
Architecture / computational structure
A coordinate-to-solution network is differentiated with automatic differentiation to form PDE/ODE residuals. Loss terms enforce observations, governing equations and boundaries; unknown physical coefficients may be optimized jointly.
Assumptions
Low residual at sampled points does not prove a globally accurate solution. Stiffness, spectral bias, unidentifiable inverse parameters, incompatible boundaries and optimization imbalance can cause failure. Physics constraints do not repair incorrect equations.
Formula / computational definition
. Here denotes physical coefficients, collocation points, and equation/boundary operators.
Parameters and notation
Learned or estimated: Network weights and biases; selected physical coefficients eta in an inverse problem. Collocation locations and loss weights are usually design variables, not unknown physical laws.
Hyperparameters and effects: Network width/depth, activation smoothness, loss weights, collocation count/distribution, nondimensionalization, optimizer and residual formulation. Weights balance units/scales; smooth activations are needed for required derivatives.
Fitting, fine-tuning, and adaptation
Fit weights and any identifiable coefficients with properly scaled terms; compare with established numerical solvers. For nearby conditions, warm-start the network but reimpose new boundaries and resample collocation points. Use small-rate adaptation, validate on independent residual points and solution data, and check source-condition retention if one model must serve several regimes.
How to use and calibrate
Define the independent evaluation unit before preprocessing: row/entity, whole set/object, molecule/trajectory, input function or chronological forecasting origin. Keep target construction and normalization within permitted training data. Report solution/derivative errors, boundary violations, residual distributions, conservation diagnostics and sensitivity to collocation density. For inverse problems quantify parameter identifiability and uncertainty rather than relying only on training loss.
Example application
Approximate a differential-equation solution while combining sparse measurements with known boundary conditions. This is a proposed use case, not a claim of validated performance on supplied real data.
Interpretation / pitfalls
Watch out
Assess model error against domain baselines and the stated assumptions. Component-level mathematical correctness does not establish paper reproduction or scientific validity. Use an independent validation design for model selection and a final held-out evaluation for claims; uncertainty and calibration require separate assessment.
Python and R code examples
Scope: Analytic Poisson residual of a tanh trial network and boundary penalty; no PDE fitting. Use the shared setup. Dependencies: NumPy / base R. Validation: Python executed; R unexecuted.
Full-model route: Python/R: native autodiff networks or a verified physics-learning library; R may bridge to Python for specialized solvers. The base-array example analytically differentiates a tanh trial network and computes a Poisson residual/boundary loss; it does not solve the PDE.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Analytic Poisson residual of a tanh trial network and boundary penalty; no PDE fitting. Use the shared setup.
Shared setup for this chapter
import numpy as np
def sm(x):
x=np.asarray(x); e=np.exp(x-x.max(axis=-1,keepdims=True)); return e/e.sum(axis=-1,keepdims=True)
x=np.linspace(0,1,51); a,b,c,d=.5,2.,-.4,0.
hidden=np.tanh(b*x+c); u=a*hidden+d
second=-2*a*b*b*hidden*(1-hidden*hidden)
forcing=np.pi**2*np.sin(np.pi*x)
residual=-second-forcing
loss=np.mean(residual**2)+10*(u[0]**2+u[-1]**2)
print('PDE loss',loss,'boundary values',u[[0,-1]])
Component demo, not a trained model — Analytic Poisson residual of a tanh trial network and boundary penalty; no PDE fitting. Use the shared setup.
Shared setup for this chapter
sm <- function(x) {
if(is.null(dim(x))) { e<-exp(x-max(x)); return(e/sum(e)) }
t(apply(x,1,function(v) { e<-exp(v-max(v)); e/sum(e) }))
}
x<-seq(0,1,length.out=51); a<-.5; b<-2; c<--.4; d<-0
hidden<-tanh(b*x+c); u<-a*hidden+d
second<--2*a*b*b*hidden*(1-hidden*hidden); forcing<-pi^2*sin(pi*x)
residual<--second-forcing; loss<-mean(residual^2)+10*(u[1]^2+tail(u,1)^2)
print(list(PDE_loss=loss,boundaries=u[c(1,length(u))]))
Sources
- Source 1arxiv.org
From the CodeSplash reference, entry SPE013.