Skip to content

Commit

Permalink
Merge branch 'SciML:master' into Bpinn_pde
Browse files Browse the repository at this point in the history
  • Loading branch information
AstitvaAggarwal authored Nov 30, 2023
2 parents dc3dceb + 80a7849 commit f91adc3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Manifest.toml
*/testlogs
docs/build/*
scratch
scratch/*
scratch/*
.DS_store
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ MonteCarloMeasurements = "1"
Optim = ">= 1.7.8"
Optimisers = "0.2, 0.3"
Optimization = "3"
QuasiMonteCarlo = "0.2.1"
QuasiMonteCarlo = "0.3.2"
RecursiveArrayTools = "2.31"
Reexport = "1.0"
RuntimeGeneratedFunctions = "0.5"
SciMLBase = "1.91, 2"
Statistics = "1"
StochasticDiffEq = "6.13"
SymbolicUtils = "1"
Symbolics = "5"
Expand All @@ -80,7 +81,6 @@ julia = "1.6"

[extras]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
IntegralsCuba = "1e5cbd8a-c439-4026-92c2-98742b2c817b"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Expand All @@ -89,4 +89,4 @@ SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "CUDA", "SafeTestsets", "OptimizationOptimisers", "OptimizationOptimJL", "Pkg", "OrdinaryDiffEq", "IntegralsCuba"]
test = ["Test", "CUDA", "SafeTestsets", "OptimizationOptimisers", "OptimizationOptimJL", "Pkg", "OrdinaryDiffEq"]
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[NeuralPDE.jl](https://github.com/SciML/NeuralPDE.jl) is a solver package which
consists of neural network solvers for partial differential equations using
physics-informed neural networks (PINNs) and the ability to generate neural
networks which both approximate physical laws and real data simultaniously.
networks which both approximate physical laws and real data simultaneously.

## Features

Expand Down
2 changes: 1 addition & 1 deletion docs/src/tutorials/ode.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
!!! note

It is highly recommended you first read the [solving ordinary differential
equations with DifferentialEquations.jl tutorial](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/ode_example/)
equations with DifferentialEquations.jl tutorial](https://docs.sciml.ai/DiffEqDocs/stable/getting_started/)
before reading this tutorial.

This tutorial is an introduction to using physics-informed neural networks (PINNs) for solving ordinary differential equations (ODEs). In contrast to the later parts of this documentation which use the symbolic interface, here we will focus on the simplified [`NNODE`](@ref) which uses the `ODEProblem` specification for the ODE.
Expand Down
2 changes: 1 addition & 1 deletion src/BPINN_ode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Kevin Linka, Amelie Schäfer, Xuhui Meng, Zongren Zou, George Em Karniadakis, El
struct BNNODE{C, K, IT <: NamedTuple,
A <: NamedTuple, H <: NamedTuple,
ST <: Union{Nothing, AbstractTrainingStrategy},
I <: Union{Nothing, Vector{<:AbstractFloat}},
I <: Union{Nothing, <:NamedTuple, Vector{<:AbstractFloat}},
P <: Union{Nothing, Vector{<:Distribution}},
D <:
Union{Vector{Nothing}, Vector{<:Vector{<:AbstractFloat}}}} <:
Expand Down
14 changes: 6 additions & 8 deletions src/advancedHMC_MCMC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ function L2LossData(Tar::LogTargetDensity, θ)
for i in 1:length(Tar.prob.u0)
# for u[i] ith vector must be added to dataset,nn[1,:] is the dx in lotka_volterra
L2logprob += logpdf(MvNormal(nn[i, :],
LinearAlgebra.Diagonal(map(abs2,
Tar.l2std[i] .*
ones(length(Tar.dataset[i]))))),
LinearAlgebra.Diagonal(abs2.(Tar.l2std[i] .*
ones(length(Tar.dataset[i]))))),
Tar.dataset[i])
end
return L2logprob
Expand Down Expand Up @@ -250,9 +249,8 @@ function innerdiff(Tar::LogTargetDensity, f, autodiff::Bool, t::AbstractVector,

# N dimensional vector if N outputs for NN(each row has logpdf of i[i] where u is vector of dependant variables)
return [logpdf(MvNormal(vals[i, :],
LinearAlgebra.Diagonal(map(abs2,
Tar.phystd[i] .*
ones(length(vals[i, :]))))),
LinearAlgebra.Diagonal(abs2.(Tar.phystd[i] .*
ones(length(vals[i, :]))))),
zeros(length(vals[i, :]))) for i in 1:length(Tar.prob.u0)]
end

Expand Down Expand Up @@ -497,7 +495,7 @@ function ahmc_bayesian_pinn_ode(prob::DiffEqBase.ODEProblem, chain;
strategy = strategy == GridTraining ? strategy(physdt) : strategy

if dataset != [nothing] &&
(length(dataset) < 2 || !(typeof(dataset) <: Vector{<:Vector{<:AbstractFloat}}))
(length(dataset) < 2 || !(dataset isa Vector{<:Vector{<:AbstractFloat}}))
throw(error("Invalid dataset. dataset would be timeseries (x̂,t) where type: Vector{Vector{AbstractFloat}"))
end

Expand Down Expand Up @@ -534,7 +532,7 @@ function ahmc_bayesian_pinn_ode(prob::DiffEqBase.ODEProblem, chain;
ninv = length(param)
priors = [
MvNormal(priorsNNw[1] * ones(nparameters),
LinearAlgebra.Diagonal(map(abs2, priorsNNw[2] .* ones(nparameters)))),
LinearAlgebra.Diagonal(abs2.(priorsNNw[2] .* ones(nparameters)))),
]

# append Ode params to all paramvector
Expand Down
2 changes: 1 addition & 1 deletion src/pinn_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct PhysicsInformedNN{T, P, PH, DER, PE, AL, ADA, LOG, K} <: AbstractPINN
log_options = LogOptions(),
iteration = nothing,
kwargs...)
multioutput = typeof(chain) <: AbstractArray
multioutput = chain isa AbstractArray

if phi === nothing
if multioutput
Expand Down

0 comments on commit f91adc3

Please sign in to comment.