Skip to content

Commit 9d3f9f0

Browse files
author
Sathvik Bhagavan
committed
docs: fix dgm example
1 parent b3c454f commit 9d3f9f0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/src/tutorials/dgm.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Deep Galerkin Method is a meshless deep learning algorithm to solve high dimensi
77
In the following example, we demonstrate computing the loss function using Quasi-Random Sampling, a sampling technique that uses quasi-Monte Carlo sampling to generate low discrepancy random sequences in high dimensional spaces.
88

99
### Algorithm
10+
1011
The authors of DGM suggest a network composed of LSTM-type layers that works well for most of the parabolic and quasi-parabolic PDEs.
1112

1213
```math
@@ -47,13 +48,15 @@ u(t, 1) & = 0
4748
```
4849

4950
### Copy- Pasteable code
51+
5052
```@example dgm
5153
using NeuralPDE
5254
using ModelingToolkit, Optimization, OptimizationOptimisers
53-
import Lux: tanh, identity
55+
using Lux: tanh, identity
5456
using Distributions
55-
import ModelingToolkit: Interval, infimum, supremum
57+
using ModelingToolkit: Interval, infimum, supremum
5658
using MethodOfLines, OrdinaryDiffEq
59+
using Plots
5760
5861
@parameters x t
5962
@variables u(..)
@@ -108,8 +111,9 @@ phi = discretization.phi
108111
u_predict= [first(phi([t, x], res.minimizer)) for t in ts, x in xs]
109112
110113
diff_u = abs.(u_predict .- u_MOL)
114+
tgrid = 0.0:0.01:1.0
115+
xgrid = -1.0:0.01:1.0
111116
112-
using Plots
113117
p1 = plot(tgrid, xgrid, u_MOL', linetype = :contourf, title = "FD");
114118
p2 = plot(tgrid, xgrid, u_predict', linetype = :contourf, title = "predict");
115119
p3 = plot(tgrid, xgrid, diff_u', linetype = :contourf, title = "error");

0 commit comments

Comments
 (0)