Skip to content

Commit

Permalink
update figures
Browse files Browse the repository at this point in the history
  • Loading branch information
vpuri3 committed Jul 2, 2024
1 parent 15d0b37 commit 5166170
Show file tree
Hide file tree
Showing 495 changed files with 2,802 additions and 826 deletions.
18 changes: 15 additions & 3 deletions experiments_SNFROM/PCA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,20 @@ function evolve_PCA(
#==============#
# get initial state
#==============#
U0_norm = normalizedata(U0, md.ū, md.σu)
p0 = P' * U0_norm[1,:]

# only out_dim == 1 supported
pl, Ul = begin
Ud_norm = normalizedata(Ud[1, :, :], md.ū, md.σu)
pl = P' * Ud_norm

Ul = unnormalizedata(P * pl, md.ū, md.σu)
Ul = reshape(Ul, 1, size(Ul)...)
Ul = repeat(Ul, out_dim, 1)

pl, Ul
end

p0 = pl[:, 1]

#==============#
# get model
Expand Down Expand Up @@ -316,7 +328,7 @@ function evolve_PCA(

# save files
filename = joinpath(outdir, "evolve$(case).jld2")
jldsave(filename; Xdata, Tdata, Udata = Ud, Upred = Up, Ppred = ps)
jldsave(filename; Xdata, Tdata, Udata = Ud, Upred = Up, Ppred = ps, Plrnd = pl, Ulrnd = Ul)

# print error metrics
@show sqrt(mse(Up, Ud) / mse(Ud, 0 * Ud))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
using NeuralROMs
using CairoMakie, LaTeXStrings
using NeuralROMs, LaTeXStrings
import CairoMakie
import CairoMakie.Makie

joinpath(pkgdir(NeuralROMs), "experiments_SNFROM", "compare.jl") |> include
#======================================================#
Expand All @@ -15,7 +16,7 @@ device = Lux.gpu_device()
makedata_kws = (; Ix = :, _Ib = [1,], Ib_ = [1,], _It = :, It_ = :)

function compare_advect1d_l()
latents = [1, 3, 4, 8, 16]
latents = [1, 2, 3, 4, 8, 12, 16, 20]#, 24]

for latent in latents
ll = lpad(latent, 2, "0")
Expand Down Expand Up @@ -57,19 +58,14 @@ function compare_advect1d_l()
postprocess_CAE(prob, datafile, modelfile_CAE; rng)
postprocess_SNF(prob, datafile, modelfile_SNL; rng, device)
postprocess_SNF(prob, datafile, modelfile_SNW; rng, device)

evolve_kw = (;)
evolve_CAE(prob, datafile, modelfile_CAE, 1; rng, evolve_kw...,)
evolve_SNF(prob, datafile, modelfile_SNL, 1; rng, evolve_kw..., device)
evolve_SNF(prob, datafile, modelfile_SNW, 1; rng, evolve_kw..., device)
end

nothing
end

#======================================================#
function plot_compare_advect1d_l()
latents = [1, 2, 3, 4, 8, 16]
latents = [1, 2, 3, 4, 8, 12, 16, 20]#, 24]

case = 1

Expand All @@ -79,6 +75,9 @@ function plot_compare_advect1d_l()
e_SNW = []

for latent in latents

@show latent

ll = lpad(latent, 2, "0")

modeldir_PCA = joinpath(@__DIR__, "model_PCA$(ll)") # traditional
Expand All @@ -96,20 +95,21 @@ function plot_compare_advect1d_l()
file_SNL = jldopen(file_SNL)
file_SNW = jldopen(file_SNW)

# Ulrnd
Ud = file_PCA["Udata"]

U_PCA = file_PCA["Upred"]
U_CAE = file_CAE["Upred"]
U_SNL = file_SNL["Upred"]
U_SNW = file_SNW["Upred"]
U_PCA = file_PCA["Ulrnd"]
U_CAE = file_CAE["Ulrnd"]
U_SNL = file_SNL["Ulrnd"]
U_SNW = file_SNW["Ulrnd"]

N = length(Ud)
Nr = sum(abs2, Ud) / N |> sqrt

er_PCA = sum(abs2, U_PCA - Ud) / N / Nr
er_CAE = sum(abs2, U_CAE - Ud) / N / Nr
er_SNL = sum(abs2, U_SNL - Ud) / N / Nr
er_SNW = sum(abs2, U_SNW - Ud) / N / Nr
er_PCA = sum(abs2, U_PCA - Ud) / N / Nr |> sqrt
er_CAE = sum(abs2, U_CAE - Ud) / N / Nr |> sqrt
er_SNL = sum(abs2, U_SNL - Ud) / N / Nr |> sqrt
er_SNW = sum(abs2, U_SNW - Ud) / N / Nr |> sqrt

push!(e_PCA, er_PCA)
push!(e_CAE, er_CAE)
Expand All @@ -118,12 +118,12 @@ function plot_compare_advect1d_l()
end

xlabel = L"N_{ROM}"
ylabel = L"e"
ylabel = L"$e_\text{proj}$"
xlabelsize = ylabelsize = 16

colors = (:orange, :green, :blue, :red, :brown,)
styles = (:solid, :dash, :dashdot, :dashdotdot, :dot)
labels = (L"POD-ROM$$", L"CAE-ROM$$", L"SNFL-ROM$$", L"SNFW-ROM$$",)
labels = (L"PODROM$$", L"CAEROM$$", L"SNFL-ROM$$", L"SNFW-ROM$$",)

kwl = Tuple(
(; color = colors[i], linestyle = styles[i], label = labels[i], linewidth = 2)
Expand All @@ -135,23 +135,26 @@ function plot_compare_advect1d_l()
for i in 1:4
)

fig = Figure(; size = (600, 400), backgroundcolor = :white, grid = :off)
fig = Makie.Figure(; size = (600, 400), backgroundcolor = :white, grid = :off)
ax = Makie.Axis(fig[1,1]; xlabel, ylabel, xlabelsize, ylabelsize, yscale = log10)

lines!(ax, latents, e_PCA; kwl[1]...)
lines!(ax, latents, e_CAE; kwl[2]...)
lines!(ax, latents, e_SNL; kwl[3]...)
lines!(ax, latents, e_SNW; kwl[4]...)
Makie.lines!(ax, latents, e_PCA; kwl[1]...)
Makie.lines!(ax, latents, e_CAE; kwl[2]...)
Makie.lines!(ax, latents, e_SNL; kwl[3]...)
Makie.lines!(ax, latents, e_SNW; kwl[4]...)

Makie.scatter!(ax, latents, e_PCA; kws[1]...)
Makie.scatter!(ax, latents, e_CAE; kws[2]...)
Makie.scatter!(ax, latents, e_SNL; kws[3]...)
Makie.scatter!(ax, latents, e_SNW; kws[4]...)

Legend(fig[0,1], ax; orientation = :horizontal, framevisible = false, unique = true)
Makie.Legend(fig[0,1], ax; orientation = :horizontal, framevisible = false, unique = true)

path1 = joinpath(pkgdir(NeuralROMs), "figs", "method", "exp_nrom.pdf")
path2 = joinpath(@__DIR__, "compare_ll_case1.pdf")

path = joinpath(pkgdir(NeuralROMs), "figs", "method", "exp_nrom.pdf")
save(path, fig)
save(path1, fig)
save(path2, fig)

fig
end
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 13 additions & 13 deletions experiments_SNFROM/advect_fourier1D/model_CAE01/statistics_01.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Epoch [0 / 0] TRAIN LOSS: 3.8386985e-5 || TEST LOSS: 3.8386985e-5
Epoch [0 / 0] TRAIN LOSS: 0.0032884406 || TEST LOSS: 0.0032884406
#======================#
TRAIN STATS
R² score: 0.9999616
MSE (mean SQR error): 3.838699e-5
RMSE (Root MSE): 0.0061957235
MAE (mean ABS error): 0.0042425254
maxAE (max ABS error) 0.073194206
Lipschitz bound: 3.2653997
R² score: 0.9966805
MSE (mean SQR error): 0.0032884406
RMSE (Root MSE): 0.05734493
MAE (mean ABS error): 0.025669334
maxAE (max ABS error) 2.4034014
Lipschitz bound: 5.103656

#======================#
#======================#
TEST STATS
R² score: 0.9999616
MSE (mean SQR error): 3.838699e-5
RMSE (Root MSE): 0.0061957235
MAE (mean ABS error): 0.0042425254
maxAE (max ABS error) 0.073194206
Lipschitz bound: 3.2653997
R² score: 0.9966805
MSE (mean SQR error): 0.003288441
RMSE (Root MSE): 0.057344932
MAE (mean ABS error): 0.025669334
maxAE (max ABS error) 2.4034014
Lipschitz bound: 5.103656

#======================#
26 changes: 13 additions & 13 deletions experiments_SNFROM/advect_fourier1D/model_CAE01/statistics_02.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Epoch [0 / 0] TRAIN LOSS: 1.9393403e-5 || TEST LOSS: 1.9393403e-5
Epoch [0 / 0] TRAIN LOSS: 0.00094652316 || TEST LOSS: 0.00094652316
#======================#
TRAIN STATS
R² score: 0.9999806
MSE (mean SQR error): 1.9393403e-5
RMSE (Root MSE): 0.004403794
MAE (mean ABS error): 0.0030551655
maxAE (max ABS error) 0.06608254
Lipschitz bound: 3.26566
R² score: 0.9990556
MSE (mean SQR error): 0.00094652316
RMSE (Root MSE): 0.030765617
MAE (mean ABS error): 0.014862344
maxAE (max ABS error) 0.9223623
Lipschitz bound: 5.3886147

#======================#
#======================#
TEST STATS
R² score: 0.9999806
MSE (mean SQR error): 1.9393405e-5
RMSE (Root MSE): 0.004403794
MAE (mean ABS error): 0.0030551655
maxAE (max ABS error) 0.06608254
Lipschitz bound: 3.26566
R² score: 0.9990556
MSE (mean SQR error): 0.00094652316
RMSE (Root MSE): 0.030765617
MAE (mean ABS error): 0.014862344
maxAE (max ABS error) 0.9223623
Lipschitz bound: 5.3886147

#======================#
26 changes: 13 additions & 13 deletions experiments_SNFROM/advect_fourier1D/model_CAE01/statistics_03.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Epoch [0 / 0] TRAIN LOSS: 9.435316e-6 || TEST LOSS: 9.435316e-6
Epoch [0 / 0] TRAIN LOSS: 0.00069662556 || TEST LOSS: 0.00069662556
#======================#
TRAIN STATS
R² score: 0.9999906
MSE (mean SQR error): 9.435316e-6
RMSE (Root MSE): 0.003071696
MAE (mean ABS error): 0.0021487463
maxAE (max ABS error) 0.038793206
Lipschitz bound: 3.2649229
R² score: 0.9993015
MSE (mean SQR error): 0.00069662556
RMSE (Root MSE): 0.026393663
MAE (mean ABS error): 0.012004193
maxAE (max ABS error) 1.1304066
Lipschitz bound: 5.395492

#======================#
#======================#
TEST STATS
R² score: 0.9999906
MSE (mean SQR error): 9.435317e-6
RMSE (Root MSE): 0.003071696
MAE (mean ABS error): 0.0021487463
maxAE (max ABS error) 0.038793206
Lipschitz bound: 3.2649229
R² score: 0.9993015
MSE (mean SQR error): 0.00069662556
RMSE (Root MSE): 0.026393663
MAE (mean ABS error): 0.012004193
maxAE (max ABS error) 1.1304066
Lipschitz bound: 5.395492

#======================#
26 changes: 13 additions & 13 deletions experiments_SNFROM/advect_fourier1D/model_CAE01/statistics_04.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Epoch [0 / 0] TRAIN LOSS: 7.624048e-6 || TEST LOSS: 7.624048e-6
Epoch [0 / 0] TRAIN LOSS: 0.000101296915 || TEST LOSS: 0.000101296915
#======================#
TRAIN STATS
R² score: 0.9999924
MSE (mean SQR error): 7.624048e-6
RMSE (Root MSE): 0.002761168
MAE (mean ABS error): 0.0019182552
maxAE (max ABS error) 0.03995377
Lipschitz bound: 3.265011
R² score: 0.9998984
MSE (mean SQR error): 0.00010129692
RMSE (Root MSE): 0.010064637
MAE (mean ABS error): 0.005334164
maxAE (max ABS error) 0.28556395
Lipschitz bound: 5.6360917

#======================#
#======================#
TEST STATS
R² score: 0.9999924
MSE (mean SQR error): 7.624048e-6
RMSE (Root MSE): 0.002761168
MAE (mean ABS error): 0.001918255
maxAE (max ABS error) 0.03995377
Lipschitz bound: 3.265011
R² score: 0.9998984
MSE (mean SQR error): 0.000101296915
RMSE (Root MSE): 0.010064637
MAE (mean ABS error): 0.0053341636
maxAE (max ABS error) 0.28556395
Lipschitz bound: 5.6360917

#======================#
26 changes: 13 additions & 13 deletions experiments_SNFROM/advect_fourier1D/model_CAE01/statistics_05.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Epoch [0 / 0] TRAIN LOSS: 4.4432627e-6 || TEST LOSS: 4.4432627e-6
Epoch [0 / 0] TRAIN LOSS: 4.514505e-5 || TEST LOSS: 4.514505e-5
#======================#
TRAIN STATS
R² score: 0.9999955
MSE (mean SQR error): 4.4432627e-6
RMSE (Root MSE): 0.0021079048
MAE (mean ABS error): 0.0014453864
maxAE (max ABS error) 0.024964094
Lipschitz bound: 3.2674487
R² score: 0.9999548
MSE (mean SQR error): 4.514505e-5
RMSE (Root MSE): 0.006719006
MAE (mean ABS error): 0.003519874
maxAE (max ABS error) 0.1967845
Lipschitz bound: 5.706291

#======================#
#======================#
TEST STATS
R² score: 0.9999955
MSE (mean SQR error): 4.443263e-6
RMSE (Root MSE): 0.002107905
MAE (mean ABS error): 0.0014453866
maxAE (max ABS error) 0.024964094
Lipschitz bound: 3.2674487
R² score: 0.9999548
MSE (mean SQR error): 4.514505e-5
RMSE (Root MSE): 0.006719007
MAE (mean ABS error): 0.0035198743
maxAE (max ABS error) 0.1967845
Lipschitz bound: 5.706291

#======================#
26 changes: 13 additions & 13 deletions experiments_SNFROM/advect_fourier1D/model_CAE01/statistics_06.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Epoch [0 / 0] TRAIN LOSS: 2.6286468e-6 || TEST LOSS: 2.6286468e-6
Epoch [0 / 0] TRAIN LOSS: 2.8584825e-5 || TEST LOSS: 2.8584825e-5
#======================#
TRAIN STATS
R² score: 0.9999974
MSE (mean SQR error): 2.6286466e-6
RMSE (Root MSE): 0.0016213101
MAE (mean ABS error): 0.0011346359
maxAE (max ABS error) 0.01995939
Lipschitz bound: 3.2689116
R² score: 0.9999714
MSE (mean SQR error): 2.8584822e-5
RMSE (Root MSE): 0.0053464775
MAE (mean ABS error): 0.0027882028
maxAE (max ABS error) 0.16993465
Lipschitz bound: 5.7346654

#======================#
#======================#
TEST STATS
R² score: 0.9999974
MSE (mean SQR error): 2.6286468e-6
RMSE (Root MSE): 0.0016213102
MAE (mean ABS error): 0.0011346359
maxAE (max ABS error) 0.01995939
Lipschitz bound: 3.2689116
R² score: 0.9999714
MSE (mean SQR error): 2.8584824e-5
RMSE (Root MSE): 0.0053464775
MAE (mean ABS error): 0.0027882028
maxAE (max ABS error) 0.16993465
Lipschitz bound: 5.7346654

#======================#
Loading

0 comments on commit 5166170

Please sign in to comment.