Skip to content
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

fix: bounds of variables in neural adapter setup #812

Merged
merged 7 commits into from
Mar 3, 2024
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- AdaptiveLoss
- Logging
- Forward
- NeuralAdapter
version:
- "1"
steps:
Expand Down
13 changes: 6 additions & 7 deletions src/neural_adapter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ function get_bounds_(domains, eqs, eltypeθ, dict_indvars, dict_depvars, strateg
for d in domains])
args = get_argument(eqs, dict_indvars, dict_depvars)

bounds = map(args) do pd
bounds = first(map(args) do pd
span = map(p -> get(dict_span, p, p), pd)
map(s -> adapt(eltypeθ, s), span)
end
bounds
end)
bounds = [getindex.(bounds, 1), getindex.(bounds, 2)]
return bounds
end

function get_loss_function_(loss, init_params, pde_system, strategy::StochasticTraining)
Expand All @@ -46,8 +47,7 @@ function get_loss_function_(loss, init_params, pde_system, strategy::StochasticT
pde_system.depvars)

eltypeθ = eltype(init_params)
bound = get_bounds_(domains, eqs, eltypeθ, dict_indvars, dict_depvars, strategy)[1]

bound = get_bounds_(domains, eqs, eltypeθ, dict_indvars, dict_depvars, strategy)
get_loss_function(loss, bound, eltypeθ, strategy)
end

Expand All @@ -62,8 +62,7 @@ function get_loss_function_(loss, init_params, pde_system, strategy::QuasiRandom
pde_system.depvars)

eltypeθ = eltype(init_params)
bound = get_bounds_(domains, eqs, eltypeθ, dict_indvars, dict_depvars, strategy)[1]

bound = get_bounds_(domains, eqs, eltypeθ, dict_indvars, dict_depvars, strategy)
get_loss_function(loss, bound, eltypeθ, strategy)
end

Expand Down
1 change: 0 additions & 1 deletion src/training_strategies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ end
function get_loss_function(loss_function, bound, eltypeθ, strategy::StochasticTraining;
τ = nothing)
points = strategy.points

loss = (θ) -> begin
sets = generate_random_points(points, bound, eltypeθ)
sets_ = adapt(parameterless_type(ComponentArrays.getdata(θ)), sets)
Expand Down
Loading
Loading