Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError when solving Parameter Identification problem using NeuralPDE.jl #829

Open
hippyhippohops opened this issue Mar 10, 2024 · 9 comments
Labels

Comments

@hippyhippohops
Copy link

Hi, I am getting the following error when trying to solve the inverse problem (learning \lambda) using NeuralPDE.jl: "KeyError: key λ not found" and it points towards the line @named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ]).My code is as follows:

using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOptimJL, LineSearches,  OptimizationOptimisers
import ModelingToolkit: Interval
using CSV
using DataFrames
using Plots
complex_scattered_field = CSV.read("/Users/aravinthkrishnan/Desktop/ComplexScatteredField.csv", DataFrame, header=false);
real_scattered_field = CSV.read("/Users/aravinthkrishnan/Desktop/RealScatteredField.csv", DataFrame, header=false); 
complex_scattered_field_matrix = Matrix(complex_scattered_field)
real_scattered_field_matrix = Matrix(real_scattered_field)
@parameters x,y, λ
@variables u(..)
Dxx = Differential(x)^2
Dyy = Differential(y)^2
frequency_of_wave = 8
#Equation
eq = Dxx(u(x, y)) + Dyy(u(x, y)) + (frequency_of_wave^2) * λ * u(x,y) ~ 0
# Boundary conditions
bcs = [u(0, y) ~ 0.0, u(1, y) ~ 0.0, u(x, 0) ~ 0.0, u(x, 1) ~ 0.0]
# Space and time domains
domains = [x ∈ Interval(0.0, 1.0), y ∈ Interval(0.0, 1.0)]
# Neural network
dim = 2 # number of dimensions
chain = Lux.Chain(Dense(dim, 3, Lux.σ), Dense(3, 2))
number_of_scattered_points = 50 #We will determine this
set_of_coordinates = []
# Discretization
dx = 0.05
discretization = PhysicsInformedNN(chain, QuadratureTraining(),param_estim = true)
@named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ])
prob = discretize(pde_system, discretization)

@sathvikbhagavan
Copy link
Member

It is working for me:

using NeuralPDE, DomainSets
@parameters x,y, λ
@variables u(..)
Dxx = Differential(x)^2
Dyy = Differential(y)^2
frequency_of_wave = 8
eq = Dxx(u(x, y)) + Dyy(u(x, y)) + (frequency_of_wave^2) * λ * u(x,y) ~ 0
bcs = [u(0, y) ~ 0.0, u(1, y) ~ 0.0, u(x, 0) ~ 0.0, u(x, 1) ~ 0.0]
domains = [x  Interval(0.0, 1.0), y  Interval(0.0, 1.0)]
@named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ])

output:

julia> @named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ])
PDESystem
Equations: Equation[Differential(y)(Differential(y)(u(x, y))) + Differential(x)(Differential(x)(u(x, y))) + 64u(x, y)*λ ~ 0]
Boundary Conditions: Equation[u(0, y) ~ 0.0, u(1, y) ~ 0.0, u(x, 0) ~ 0.0, u(x, 1) ~ 0.0]
Domain: Symbolics.VarDomainPairing[Symbolics.VarDomainPairing(x, 0.0 .. 1.0), Symbolics.VarDomainPairing(y, 0.0 .. 1.0)]
Dependent Variables: Num[u(x, y)]
Independent Variables: Num[x, y]
Parameters: Num[λ]
Default Parameter ValuesDict{Any, Any}()

Can you post the exact stack trace?

@hippyhippohops
Copy link
Author

1-element ExceptionStack:
LoadError: KeyError: key λ not found
Stacktrace:
  [1] getindex
    @ ./dict.jl:498 [inlined]
  [2] #316
    @ ./none:0 [inlined]
  [3] iterate
    @ ./generator.jl:47 [inlined]
  [4] collect(itr::Base.Generator{Vector{Num}, NeuralPDE.var"#316#335"{Dict{Any, Any}}})
    @ Base ./array.jl:834
  [5] symbolic_discretize(pde_system::PDESystem, discretization::PhysicsInformedNN{QuadratureTraining{Integrals.CubatureJLh, Float64}, Nothing, NeuralPDE.Phi{Chain{@NamedTuple{layer_1::Dense{true, typeof(sigmoid_fast), typeof(glorot_uniform), typeof(zeros32)}, layer_2::Dense{true, typeof(identity), typeof(glorot_uniform), typeof(zeros32)}}, Nothing}, @NamedTuple{layer_1::@NamedTuple{}, layer_2::@NamedTuple{}}}, typeof(NeuralPDE.numeric_derivative), Bool, Nothing, Nothing, Nothing, @Kwargs{}})
    @ NeuralPDE ~/.julia/packages/NeuralPDE/z18Qg/src/discretize.jl:376
  [6] discretize(pde_system::PDESystem, discretization::PhysicsInformedNN{QuadratureTraining{Integrals.CubatureJLh, Float64}, Nothing, NeuralPDE.Phi{Chain{@NamedTuple{layer_1::Dense{true, typeof(sigmoid_fast), typeof(glorot_uniform), typeof(zeros32)}, layer_2::Dense{true, typeof(identity), typeof(glorot_uniform), typeof(zeros32)}}, Nothing}, @NamedTuple{layer_1::@NamedTuple{}, layer_2::@NamedTuple{}}}, typeof(NeuralPDE.numeric_derivative), Bool, Nothing, Nothing, Nothing, @Kwargs{}})
    @ NeuralPDE ~/.julia/packages/NeuralPDE/z18Qg/src/discretize.jl:708
  [7] top-level scope
    @ ~/Desktop/Physics_Induced_Neural_Network_I.jl:69
  [8] eval
    @ ./boot.jl:385 [inlined]
  [9] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:2076
 [10] include_string(m::Module, txt::String, fname::String)
    @ Base ./loading.jl:2086
 [11] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:892
 [12] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:889
 [13] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:263
 [14] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:181
 [15] withpath(f::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/repl.jl:274
 [16] (::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:179
 [17] hideprompt(f::VSCodeServer.var"#66#71"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/repl.jl:38
 [18] (::VSCodeServer.var"#65#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:150
 [19] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:515
 [20] with_logger
    @ ./logging.jl:627 [inlined]
 [21] (::VSCodeServer.var"#64#69"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:255
 [22] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [23] invokelatest(::Any)
    @ Base ./essentials.jl:889
 [24] (::VSCodeServer.var"#62#63")()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.73.2/scripts/packages/VSCodeServer/src/eval.jl:34
in expression starting at /Users/aravinthkrishnan/Desktop/Physics_Induced_Neural_Network_I.jl:69

@sathvikbhagavan
Copy link
Member

Try giving a default value for lambda:

@named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ]; defaults = Dict=> 1.0))

@hippyhippohops
Copy link
Author

That leads to this error:

ERROR: type NamedTuple has no field layer_1
Stacktrace:
  [1] getproperty
    @ ./Base.jl:37 [inlined]
  [2] getindex(::ComponentArrays.Axis{…}, s::Symbol)
    @ ComponentArrays ~/.julia/packages/ComponentArrays/OQPt7/src/axis.jl:157
  [3] _broadcast_getindex_evalf
    @ ./broadcast.jl:709 [inlined]
  [4] _broadcast_getindex
    @ ./broadcast.jl:682 [inlined]
  [5] (::Base.Broadcast.var"#31#32"{Base.Broadcast.Broadcasted{…}})(k::Int64)
    @ Base.Broadcast ./broadcast.jl:1118
  [6] ntuple
    @ ./ntuple.jl:48 [inlined]
  [7] copy
    @ ./broadcast.jl:1118 [inlined]
  [8] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.Style{…}, Nothing, typeof(getindex), Tuple{…}})
    @ Base.Broadcast ./broadcast.jl:903
  [9] #s38#57
    @ ~/.julia/packages/ComponentArrays/OQPt7/src/array_interface.jl:120 [inlined]
 [10] var"#s38#57"(::Any, index_fun::Any, x::Any, idx::Any)
    @ ComponentArrays ./none:0
 [11] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any})
    @ Core ./boot.jl:602
 [12] getproperty
    @ ~/.julia/packages/ComponentArrays/OQPt7/src/namedtuple_interface.jl:14 [inlined]
 [13] macro expansion
    @ ~/.julia/packages/Lux/Bs5su/src/layers/containers.jl:0 [inlined]
 [14] applychain(layers::@NamedTuple{…}, x::Matrix{…}, ps::ComponentArrays.ComponentVector{…}, st::@NamedTuple{…})
    @ Lux ~/.julia/packages/Lux/Bs5su/src/layers/containers.jl:481
 [15] Chain
    @ ~/.julia/packages/Lux/Bs5su/src/layers/containers.jl:479 [inlined]
 [16] Phi
    @ ~/.julia/packages/NeuralPDE/z18Qg/src/pinn_types.jl:505 [inlined]
 [17] #32
    @ ~/.julia/packages/NeuralPDE/z18Qg/src/pinn_types.jl:511 [inlined]
 [18] numeric_derivative(phi::NeuralPDE.Phi{…}, u::NeuralPDE.var"#32#33", x::Matrix{…}, εs::Vector{…}, order::Int64, θ::ComponentArrays.ComponentVector{…})
    @ NeuralPDE ~/.julia/packages/NeuralPDE/z18Qg/src/pinn_types.jl:544
 [19] macro expansion
    @ ~/.julia/packages/NeuralPDE/z18Qg/src/discretize.jl:140 [inlined]
 [20] macro expansion
    @ ~/.julia/packages/RuntimeGeneratedFunctions/Yo8zx/src/RuntimeGeneratedFunctions.jl:163 [inlined]
 [21] macro expansion
    @ ./none:0 [inlined]
 [22] generated_callfunc(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{…}, ::Matrix{…}, ::ComponentArrays.ComponentVector{…}, ::NeuralPDE.Phi{…}, ::typeof(NeuralPDE.numeric_derivative), ::NeuralPDE.var"#300#307"{…}, ::NeuralPDE.var"#32#33", ::Vector{…})
    @ NeuralPDE ./none:0
 [23] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{…})(::Matrix{…}, ::ComponentArrays.ComponentVector{…}, ::NeuralPDE.Phi{…}, ::Function, ::Function, ::Function, ::Vector{…})
    @ RuntimeGeneratedFunctions ~/.julia/packages/RuntimeGeneratedFunctions/Yo8zx/src/RuntimeGeneratedFunctions.jl:150
 [24] #240
    @ ~/.julia/packages/NeuralPDE/z18Qg/src/discretize.jl:161 [inlined]
 [25] (::NeuralPDE.var"#integrand#138"{…})(x::Matrix{…}, θ::ComponentArrays.ComponentVector{…})
    @ NeuralPDE ~/.julia/packages/NeuralPDE/z18Qg/src/training_strategies.jl:316
 [26] BatchIntegralFunction
    @ ~/.julia/packages/SciMLBase/m3AcC/src/scimlfunctions.jl:2207 [inlined]
 [27] __solvebp_call(prob::IntegralProblem{…}, alg::Integrals.CubatureJLh, sensealg::Integrals.ReCallVJP{…}, domain::Tuple{…}, p::ComponentArrays.ComponentVector{…}; reltol::Float64, abstol::Float64, maxiters::Int64)
    @ IntegralsCubatureExt ~/.julia/packages/Integrals/uahDt/ext/IntegralsCubatureExt.jl:17
 [28] __solvebp_call
    @ ~/.julia/packages/Integrals/uahDt/ext/IntegralsCubatureExt.jl:7 [inlined]
 [29] #__solvebp_call#4
    @ ~/.julia/packages/Integrals/uahDt/src/common.jl:115 [inlined]
 [30] __solvebp_call
    @ ~/.julia/packages/Integrals/uahDt/src/common.jl:114 [inlined]
 [31] #rrule#15
    @ ~/.julia/packages/Integrals/uahDt/ext/IntegralsZygoteExt.jl:21 [inlined]
 [32] rrule
    @ ~/.julia/packages/Integrals/uahDt/ext/IntegralsZygoteExt.jl:17 [inlined]
 [33] rrule
    @ ~/.julia/packages/ChainRulesCore/hsloW/src/rules.jl:140 [inlined]
 [34] chain_rrule_kw
    @ ~/.julia/packages/Zygote/jxHJc/src/compiler/chainrules.jl:235 [inlined]
 [35] macro expansion
    @ ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0 [inlined]
 [36] _pullback(::Zygote.Context{…}, ::typeof(Core.kwcall), ::@NamedTuple{…}, ::typeof(Integrals.__solvebp), ::Integrals.IntegralCache{…}, ::Integrals.CubatureJLh, ::Integrals.ReCallVJP{…}, ::Tuple{…}, ::ComponentArrays.ComponentVector{…})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:81
 [37] solve!
    @ ~/.julia/packages/Integrals/uahDt/src/common.jl:105 [inlined]
 [38] _pullback(ctx::Zygote.Context{…}, f::typeof(solve!), args::Integrals.IntegralCache{…})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [39] #solve#3
    @ ~/.julia/packages/Integrals/uahDt/src/common.jl:101 [inlined]
 [40] _pullback(::Zygote.Context{…}, ::Integrals.var"##solve#3", ::@Kwargs{…}, ::typeof(solve), ::IntegralProblem{…}, ::Integrals.CubatureJLh)
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [41] solve
    @ ~/.julia/packages/Integrals/uahDt/src/common.jl:98 [inlined]
 [42] _pullback(::Zygote.Context{…}, ::typeof(Core.kwcall), ::@NamedTuple{…}, ::typeof(solve), ::IntegralProblem{…}, ::Integrals.CubatureJLh)
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [43] #134
    @ ~/.julia/packages/NeuralPDE/z18Qg/src/training_strategies.jl:320 [inlined]
 [44] _pullback(::Zygote.Context{…}, ::NeuralPDE.var"#134#137"{…}, ::Vector{…}, ::Vector{…}, ::NeuralPDE.var"#240#241"{…}, ::ComponentArrays.ComponentVector{…})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [45] #135
    @ ~/.julia/packages/NeuralPDE/z18Qg/src/training_strategies.jl:326 [inlined]
 [46] _pullback(ctx::Zygote.Context{…}, f::NeuralPDE.var"#135#139"{…}, args::ComponentArrays.ComponentVector{…})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [47] #324
    @ ./none:0 [inlined]
 [48] _pullback(ctx::Zygote.Context{…}, f::NeuralPDE.var"#324#345"{…}, args::NeuralPDE.var"#135#139"{…})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [49] #662
    @ ~/.julia/packages/Zygote/jxHJc/src/lib/array.jl:187 [inlined]
 [50] iterate
    @ ./generator.jl:47 [inlined]
 [51] _collect(c::Vector{…}, itr::Base.Generator{…}, ::Base.EltypeUnknown, isz::Base.HasShape{…})
    @ Base ./array.jl:854
 [52] collect_similar
    @ ./array.jl:763 [inlined]
 [53] map
    @ ./abstractarray.jl:3285 [inlined]
 [54] ∇map(cx::Zygote.Context{…}, f::NeuralPDE.var"#324#345"{…}, args::Vector{…})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/lib/array.jl:187
 [55] _pullback
    @ ~/.julia/packages/Zygote/jxHJc/src/lib/array.jl:230 [inlined]
 [56] full_loss_function
    @ ~/.julia/packages/NeuralPDE/z18Qg/src/discretize.jl:532 [inlined]
 [57] _pullback(::Zygote.Context{…}, ::NeuralPDE.var"#full_loss_function#344"{…}, ::ComponentArrays.ComponentVector{…}, ::SciMLBase.NullParameters)
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [58] _apply(::Function, ::Vararg{Any})
    @ Core ./boot.jl:838
 [59] adjoint
    @ ~/.julia/packages/Zygote/jxHJc/src/lib/lib.jl:203 [inlined]
 [60] _pullback
    @ ~/.julia/packages/ZygoteRules/M4xmc/src/adjoint.jl:67 [inlined]
 [61] OptimizationFunction
    @ ~/.julia/packages/SciMLBase/m3AcC/src/scimlfunctions.jl:3667 [inlined]
 [62] _pullback(::Zygote.Context{…}, ::OptimizationFunction{…}, ::ComponentArrays.ComponentVector{…}, ::SciMLBase.NullParameters)
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [63] _apply(::Function, ::Vararg{Any})
    @ Core ./boot.jl:838
 [64] adjoint
    @ ~/.julia/packages/Zygote/jxHJc/src/lib/lib.jl:203 [inlined]
 [65] _pullback
    @ ~/.julia/packages/ZygoteRules/M4xmc/src/adjoint.jl:67 [inlined]
 [66] #37
    @ ~/.julia/packages/Optimization/Zc00b/ext/OptimizationZygoteExt.jl:88 [inlined]
 [67] _pullback(ctx::Zygote.Context{…}, f::OptimizationZygoteExt.var"#37#55"{…}, args::ComponentArrays.ComponentVector{…})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [68] _apply(::Function, ::Vararg{Any})
    @ Core ./boot.jl:838
 [69] adjoint
    @ ~/.julia/packages/Zygote/jxHJc/src/lib/lib.jl:203 [inlined]
 [70] _pullback
    @ ~/.julia/packages/ZygoteRules/M4xmc/src/adjoint.jl:67 [inlined]
 [71] #39
    @ ~/.julia/packages/Optimization/Zc00b/ext/OptimizationZygoteExt.jl:91 [inlined]
 [72] _pullback(ctx::Zygote.Context{…}, f::OptimizationZygoteExt.var"#39#57"{…}, args::ComponentArrays.ComponentVector{…})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface2.jl:0
 [73] pullback(f::Function, cx::Zygote.Context{false}, args::ComponentArrays.ComponentVector{Float64, Vector{…}, Tuple{…}})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface.jl:90
 [74] pullback
    @ ~/.julia/packages/Zygote/jxHJc/src/compiler/interface.jl:88 [inlined]
 [75] gradient(f::Function, args::ComponentArrays.ComponentVector{Float64, Vector{Float64}, Tuple{ComponentArrays.Axis{…}}})
    @ Zygote ~/.julia/packages/Zygote/jxHJc/src/compiler/interface.jl:147
 [76] (::OptimizationZygoteExt.var"#38#56"{…})(::ComponentArrays.ComponentVector{…}, ::ComponentArrays.ComponentVector{…})
    @ OptimizationZygoteExt ~/.julia/packages/Optimization/Zc00b/ext/OptimizationZygoteExt.jl:91
 [77] (::OptimizationOptimJL.var"#8#14"{…})(G::ComponentArrays.ComponentVector{…}, θ::ComponentArrays.ComponentVector{…})
    @ OptimizationOptimJL ~/.julia/packages/OptimizationOptimJL/yMF3E/src/OptimizationOptimJL.jl:163
 [78] value_gradient!!(obj::TwiceDifferentiable{…}, x::ComponentArrays.ComponentVector{…})
    @ NLSolversBase ~/.julia/packages/NLSolversBase/kavn7/src/interface.jl:82
 [79] initial_state(method::BFGS{…}, options::Optim.Options{…}, d::TwiceDifferentiable{…}, initial_x::ComponentArrays.ComponentVector{…})
    @ Optim ~/.julia/packages/Optim/EJwLF/src/multivariate/solvers/first_order/bfgs.jl:94
 [80] optimize(d::TwiceDifferentiable{…}, initial_x::ComponentArrays.ComponentVector{…}, method::BFGS{…}, options::Optim.Options{…})
    @ Optim ~/.julia/packages/Optim/EJwLF/src/multivariate/optimize/optimize.jl:36
 [81] __solve(cache::OptimizationCache{…})
    @ OptimizationOptimJL ~/.julia/packages/OptimizationOptimJL/yMF3E/src/OptimizationOptimJL.jl:212
 [82] solve!(cache::OptimizationCache{…})
    @ SciMLBase ~/.julia/packages/SciMLBase/m3AcC/src/solve.jl:180
 [83] solve(::OptimizationProblem{…}, ::BFGS{…}; kwargs::@Kwargs{…})
    @ SciMLBase ~/.julia/packages/SciMLBase/m3AcC/src/solve.jl:96
Some type information was truncated. Use `show(err)` to see complete types.

@sathvikbhagavan
Copy link
Member

What line?

@hippyhippohops
Copy link
Author

After I changed @named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ]) to @named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ]; defaults = Dict(λ => 1.0))

@sathvikbhagavan
Copy link
Member

Try:

chain = [Lux.Chain(Dense(dim, 3, Lux.σ), Dense(3, 2))]

instead of

chain = Lux.Chain(Dense(dim, 3, Lux.σ), Dense(3, 2))

BTW, I feel the output dimension should be 1 instead of 2.

@ayushinav
Copy link
Contributor

ayushinav commented Mar 10, 2024

Try giving a default value for lambda:

@named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ]; defaults = Dict=> 1.0))

I had some time and was looking into it. This seems to work for me. We can probably do something like returning a default value here (like zero(typeof(defaults[ep])) oreps((typeof(defaults[ep]))) instead of nothing and put an info/warn out?

@hippyhippohops
Copy link
Author

Try:

chain = [Lux.Chain(Dense(dim, 3, Lux.σ), Dense(3, 2))]

instead of

chain = Lux.Chain(Dense(dim, 3, Lux.σ), Dense(3, 2))

BTW, I feel the output dimension should be 1 instead of 2.

This worked for me. Why does making it an array help? Is it because of the following: chain: a vector of Lux/Flux chains with a d-dimensional input and a 1-dimensional output corresponding to each of the dependent variables (gotten from https://docs.sciml.ai/NeuralPDE/stable/manual/pinns/).

Regarding this,

I had some time and was looking into it. This seems to work for me. We can probably do something like returning a default value here (like zero(typeof(defaults[ep])) oreps((typeof(defaults[ep]))) instead of nothing and put an info/warn out?

should I do a pull request and change it such that it returns a default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants