Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AstitvaAggarwal committed Sep 1, 2023
1 parent 09c0620 commit 51ecb37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
13 changes: 7 additions & 6 deletions src/advancedHMC_MCMC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,16 @@ end
# My suggested extra loss function
function L2loss2(Tar::LogTargetDensity, θ)
f = Tar.prob.f
dataset = Tar.dataset

# Timepoints to enforce Physics
dataset = Array(reduce(hcat, dataset)')
t = dataset[end, :]
= dataset[1:(end - 1), :]

# parameter estimation chosen or not
if Tar.extraparams > 0
dataset = Tar.dataset

# Timepoints to enforce Physics
dataset = Array(reduce(hcat, dataset)')
t = dataset[end, :]
= dataset[1:(end - 1), :]

ode_params = Tar.extraparams == 1 ?
θ[((length(θ) - Tar.extraparams) + 1):length(θ)][1] :
θ[((length(θ) - Tar.extraparams) + 1):length(θ)]
Expand Down
7 changes: 3 additions & 4 deletions test/BPINN_Tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,9 @@ fh_mcmc_chain1, fhsamples1, fhstats1 = ahmc_bayesian_pinn_ode(prob, chainflux1,
3.0),
param = [
LogNormal(9,
0.5),
5),
],
Metric = DiagEuclideanMetric,
n_leapfrog = 30)
Metric = DiagEuclideanMetric)

fh_mcmc_chain2, fhsamples2, fhstats2 = ahmc_bayesian_pinn_ode(prob, chainlux1,
dataset = dataset,
Expand Down Expand Up @@ -187,7 +186,7 @@ meanscurve2 = prob.u0 .+ (t .- prob.tspan[1]) .* luxmean

# ESTIMATED ODE PARAMETERS (NN1 AND NN2)
@test abs(p - mean([fhsamples2[i][23] for i in 2000:2500])) < abs(0.2 * p)
@test abs(p - mean([fhsamples1[i][26] for i in 2000:2500])) < abs(0.2 * p)
@test abs(p - mean([fhsamples1[i][23] for i in 2000:2500])) < abs(0.2 * p)

#---------------------- solve() call
@test mean(abs.(x̂1 .- sol2flux.ensemblesol)) < 5e-1
Expand Down

0 comments on commit 51ecb37

Please sign in to comment.