-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Parameters estimation using NeuralPDE.jl is not working for PDEs #681
Comments
MWE? |
I've already ID'd the problem and the workaround: |
I believe it's a different point here as the training process does not even start |
solved |
Hello, I am relatively new to Julia and NeuralPDE. For learning purposes, I am trying to solve an inverse problem related to a simple Poiseuille flow. I seem to be encountering the same issue that was mentioned earlier. Unfortunately, I'm struggling to understand why this is happening. I get the following error at the beginning of the ERROR: type NamedTuple has no field layer_1 Could anyone explain how the issue was resolved previously, or possibly assist me in debugging my code? The PDE that I'm working with is: where Here, using SciMLBase
using NeuralPDE, ModelingToolkit, Lux, Optimization, OptimizationOptimJL
using Plots
using Pipe
R = 10.0
l = 2.0
ΔP = 15
μ = 3.2
analytical = function (y::Real, R::Real, l::Real, ΔP::Real, μ::Real)
ΔP / (4 * μ * l) * R^2 * (1 - y^2)
end
ndata = 10
noise_fact = 0.1
y_data = reshape(range(0, 1, ndata), 1, ndata)
w_data = analytical.(y_data, R, l, ΔP, μ) .+ noise_fact * analytical(0, R, l, ΔP, μ) * randn(size(y_data))
@parameters y, w̃ₛ
@variables w̃(..)
Dy = Differential(y)
Dyy = Differential(y)^2
eq = Dyy(w̃(y)) + 1 / y * Dy(w̃(y)) + w̃ₛ ~ 0
bcs = [w̃(1) ~ 0]
ε = 1e-9 #Avoir cost function evaluation at y=0
domains = [y ∈ (ε, 1)]
@named pde_system = PDESystem(eq, bcs, domains, [y], [w̃(y)], [w̃ₛ], defaults=Dict(w̃ₛ => 1.0))
chain = Chain(Dense(1, 4, Lux.σ), Dense(4, 1, Lux.σ))
additional_loss = function (phi, θ, p)
sum(abs2, phi(y_data, θ) - w_data)
end
callback = function (p, l)
println("Current loss is: $l")
return false
end
pinn_inv = NeuralPDE.PhysicsInformedNN(chain, QuasiRandomTraining(100), additional_loss=additional_loss, param_estim=true)
prob_inv = NeuralPDE.discretize(pde_system, pinn_inv)
res_inv = Optimization.solve(prob_inv, BFGS(); maxiters=5000)
y_plot = range(0, 1, 100)
plot(y_plot, analytical.(y_plot, R, l, ΔP, μ), label="analytical")
plot!(y_plot, @pipe(y_plot |> reshape(_, 1, length(_)) |> pinn.phi(_, res_inv.u)'), label="PINN")
plot!(y_data', w_data', seriestype=:scatter, label="data")
The Status `~/infrastructure_ae/Project.toml`
[b2108857] Lux v0.4.54
[961ee093] ModelingToolkit v8.59.1
[315f7962] NeuralPDE v5.7.0
[7f7a1694] Optimization v3.15.2
[36348300] OptimizationOptimJL v0.1.9
[b98c9c47] Pipe v1.3.0
[91a5bcdd] Plots v1.38.16
[0bca4576] SciMLBase v1.93.0 |
Hello,
![image](https://user-images.githubusercontent.com/123549342/235362981-9f9a0c70-f6fd-4221-b077-b1f0bf29fad5.png)
The inverse PINN problems handling partial differential equations does not work well as the code stops at the optimization (training ) step and the following error appears:
ERROR: type NamedTuple has no field layer_1
While it works well with ordinary differential equations such as Lorenz eqs example illustrated in the package's docs.
The used Julia version: 1.8.5
The text was updated successfully, but these errors were encountered: