Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
trontrytel committed Mar 5, 2024
1 parent 1f7aa3f commit a3d4ab7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
File renamed without changes.
19 changes: 11 additions & 8 deletions test/emulator_NN.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ function MLJFlux.build(builder::NNBuilder, rng, n_in, n_out)
return Flux.Chain(layers...)
end

# Path to ML testing folder (stores some common functions, downloaded data
# and the created emulator)
fpath = joinpath(pkgdir(CM), "test_ml")
# Load aerosol data reading and preprocessing functions
include(joinpath(fpath, "Common.jl"))
include(joinpath(pkgdir(CM), "ext", "Common.jl"))

# Get the ML model
function get_ML_model(machine_name, FT)
function get_2modal_NN_model_FT32()
FT = Float32
machine_name = "2modal_nn_machine_naive.jls"

# If the ML model already exists load it in.
# If it does not exist, train a NN
fpath = joinpath(pkgdir(CM), "test")
if isfile(joinpath(fpath, machine_name))
# Read-in the saved ML model
emulator_filepath = joinpath(fpath, machine_name)
Expand Down Expand Up @@ -154,12 +155,14 @@ function test_emulator_NN(FT)
ad = AM.AerosolDistribution((crs, acc))

# Get the ML model
mach = get_ML_model("2modal_nn_machine_naive.jls", FT)
mach = get_2modal_NN_model_FT32()

TT.@test AA.N_activated_per_mode(mach, ap, ad, aip, tps, T, p, w, q)[1]
FT(999964.4226498074)
AA.N_activated_per_mode(ap, ad, aip, tps, T, p, w, q)[1] rtol =
1e-5
TT.@test AA.N_activated_per_mode(mach, ap, ad, aip, tps, T, p, w, q)[2]
FT(9.998556592247702e7)
AA.N_activated_per_mode(ap, ad, aip, tps, T, p, w, q)[2] rtol =
1e-3
end

@info "Aerosol activation NN test"
Expand Down
12 changes: 0 additions & 12 deletions test_ml/Project.toml

This file was deleted.

0 comments on commit a3d4ab7

Please sign in to comment.