Derivatives with AD and FDM
1
PINN Workflow
2
Total loss
Derivatives
PINN Workflow (Simplified)
3
Total loss
Derivatives
PINN Workflow
4
Total loss
Derivatives
AD or FDM
Automatic Differentiation (AD)
5
Elementary
operations
Local derivatives
×
σ
+
×
Computation graph
AD
6
×
σ
+
×
AD
7
×
σ
+
×
σ’
×
Finite Difference Method (FDM)
8
FDM
9
AD vs FDM in PINN
10
AD:
FDM:
Autograd
AD vs FDM in PINN
11
AD
FDM
AD: Strengths and Weaknesses
12
Arbitrary collocation points
FDM: Strengths and Weaknesses
13
Derivative from local neighboring predictions
FDM error due to finite h
Effect of Step Size h
14
Code Example
15
Heat Source: Gaussian Heater
16
Collocation Points
17
Neural Network and Loss
18
PDE: AD
19
PDE: FDM
20
Train
21
Results
22
Method | Relative L2 Error | No. of epochs | Maximum T (°C) | Training time (s) | Peak GPU Memory (MB) |
AD-PINN | 1.932e-03 | 20000 | 21.627 | 168.14 | 22.25 |
FDM-PINN | 3.903e-03 | 20000 | 21.640 | 138.44 | 19.30 |
AD vs FDM: Selection
23
Prefer AD when… | Prefer FDM when… |
Collocation points are arbitrary/scattered | Structured field/image output |
Coordinates are explicit NN inputs | High-order AD is computationally expensive |
Discretization error matters | Memory constraints |
Summary
24