Training a physics-informed neural field #
Solve u''(x) = -2 on [-1, 1], with u(-1) = u(1) = 0. The exact solution is 1 - x²,
but training only sees the equation and boundary conditions, not samples of that solution.
A tanh MLP represents the field. The objective is half the mean squared equation residual plus
half the mean squared boundary residual. derivativeVjp differentiates the second coordinate
derivative with respect to all model parameters; ordinary SGD then updates the same typed state.
This is a small CPU example of the residual method of Raissi, Perdikaris, and Karniadakis, "Physics-informed neural networks", Journal of Computational Physics 378 (2019), 686–707. The reported residuals are sampled diagnostics, not a uniform PDE certificate.
A smooth neural field; tanh permits the second derivatives in the equation residual.
Instances For
The equation is imposed at five interior collocation points.
Instances For
Evaluate the residual objective and accumulate its parameter gradient.
Instances For
Fit the equation and boundary conditions, then compare with the held-out exact solution.