I want to solve a 2D Poisson equation, so im trying to run a Physics-Informed Neural Network in Julia using the NeuralPDE.jl package, this is the code (I got it here):
using NeuralPDE, Flux, ModelingToolkit, GalacticOptim, Optim, DiffEqFlux
@parameters x y
@variables u(..)
@derivatives Dxx''~x
@derivatives Dyy''~y
# 2D PDE
eq = Dxx(u(x,y)) + Dyy(u(x,y)) ~ -sin(pi*x)*sin(pi*y)
# Boundary conditions
bcs = [u(0,y) ~ 0.f0, u(1,y) ~ -sin(pi*1)*sin(pi*y),
u(x,0) ~ 0.f0, u(x,1) ~ -sin(pi*x)*sin(pi*1)]
# Space and time domains
domains = [x ∈ IntervalDomain(0.0,1.0),
y ∈ IntervalDomain(0.0,1.0)]
# Neural network
dim = 2 # number of dimensions
chain = FastChain(FastDense(dim,16,Flux.σ),FastDense(16,16,Flux.σ),FastDense(16,1))
# Discretization
dx = 0.05
discretization = PhysicsInformedNN(chain,GridTraining())
pde_system = PDESystem(eq,bcs,domains,[x,y],[u])
prob = discretize(pde_system,discretization)
but i get this error:
WARNING: could not import DistributionsAD._mv_categorical_logpdf into ReverseDiffX
ERROR: LoadError: MethodError: no method matching zero(::FastChain{Tuple{FastDense{typeof(σ),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}},FastDense{typeof(σ),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}},FastDense{typeof(identity),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}}}})
Closest candidates are:
zero(!Matched::Type{Missing}) at missing.jl:103
zero(!Matched::Type{LibGit2.GitHash}) at /build/julia-98cBbp/julia-1.4.1+dfsg/usr/share/julia/stdlib/v1.4/LibGit2/src/oid.jl:220
zero(!Matched::Type{Pkg.Resolve.VersionWeight}) at /build/julia-98cBbp/julia-1.4.1+dfsg/usr/share/julia/stdlib/v1.4/Pkg/src/Resolve/versionweights.jl:15
...
Stacktrace:
[1] _colon(::Float64, ::Function, ::Float64) at ./range.jl:45
[2] (::Colon)(::Float64, ::Function, ::Float64) at ./range.jl:41
[3] (::NeuralPDE.var"#150#157")(::Tuple{ModelingToolkit.VarDomainPairing,FastChain{Tuple{FastDense{typeof(σ),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}},FastDense{typeof(σ),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}},FastDense{typeof(identity),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}}}}}) at ./none:0
[4] iterate at ./generator.jl:47 [inlined]
[5] collect(::Base.Generator{Base.Iterators.Zip{Tuple{Array{ModelingToolkit.VarDomainPairing,1},Array{FastChain{Tuple{FastDense{typeof(σ),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}},FastDense{typeof(σ),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}},FastDense{typeof(identity),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}}}},1}}},NeuralPDE.var"#150#157"}) at ./array.jl:665
[6] generate_training_sets(::Array{ModelingToolkit.VarDomainPairing,1}, ::Function, ::Array{Equation,1}, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Dict{Symbol,Int64}, ::Dict{Symbol,Int64}) at /home/suribe06/.julia/packages/NeuralPDE/7SDF6/src/pinns_pde_solve.jl:297
[7] discretize(::PDESystem, ::PhysicsInformedNN{FastChain{Tuple{FastDense{typeof(σ),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}},FastDense{typeof(σ),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}},FastDense{typeof(identity),DiffEqFlux.var"#initial_params#130"{typeof(Flux.glorot_uniform),typeof(Flux.zeros),Int64,Int64}}}},GridTraining,Array{Float32,1},NeuralPDE.var"#165#167"{Flux.var"#34#36"{GridTraining}},NeuralPDE.var"#168#169"{Float32},GridTraining,Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}}) at /home/suribe06/.julia/packages/NeuralPDE/7SDF6/src/pinns_pde_solve.jl:418
[8] top-level scope at /home/suribe06/github/Modeling-Simulation-2/Project/PINN.jl:28
[9] include(::Module, ::String) at ./Base.jl:377
[10] exec_options(::Base.JLOptions) at ./client.jl:288
[11] _start() at ./client.jl:484
in expression starting at /home/suribe06/github/Modeling-Simulation-2/Project/PINN.jl:28
The error is in the last line:
prob = discretize(pde_system,discretization)
What I'm doing wrong and/or how I can fix it?