-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move EKP state update to Accelerator function initial setup of Nesterov momentum fixes for indexing, typos, constructors undo accidental test changes accelerator struct fixes sanity-check comparison on simple problem fixed index shift, added function to set accelerator ICs add exp sin example convergence plots reproduced multi-trial convergence results on exp sin IP fix bug with accelerator setup in default case visualize momentum acceleration in EKI,EKS processes darcy in progress accelerator work and unit tests formatting undo formatting Move EKP state update to Accelerator function initial setup of Nesterov momentum fixes for indexing, typos, constructors undo accidental test changes accelerator struct fixes sanity-check comparison on simple problem fixed index shift, added function to set accelerator ICs add exp sin example convergence plots reproduced multi-trial convergence results on exp sin IP fix bug with accelerator setup in default case visualize momentum acceleration in EKI,EKS processes darcy in progress accelerator work and unit tests ignore UKI, fix tests Delete examples/LearningRateSchedulers/compare_schedulers_accelerated.jl Delete examples/Sinusoid/exp_sin_multi_comparison.pdf Delete examples/Sinusoid/exp_sin.pdf Delete examples/Sinusoid/exp_sin_.pdf Delete examples/Sinusoid/exp_sin_eki.pdf Delete examples/Sinusoid/exp_sin_eks.pdf Delete examples/Sinusoid/exp_sin_multi_comparison_a.pdf Delete examples/Sinusoid/exp_sin_multi_comparison_b.pdf Delete examples/Sinusoid/exp_sin_multi_comparison_c.pdf Delete examples/Sinusoid/exp_sin_narrow.pdf Delete examples/Sinusoid/exp_sin_targeted.pdf Delete examples/Sinusoid/exp_sin_shifted.pdf Delete examples/Sinusoid/exp_sin_wide.pdf Delete examples/Sinusoid/exp_sinusoid_example_accelerated.jl Delete examples/Sinusoid/exp_sinusoid_example_comparison.jl Delete examples/Sinusoid/sinusoid_example_accelerated.jl Delete test/Accelerators directory Accelerator tests will be condensed with EKP tests Delete output/ensembles_acc.pdf Delete output/error_vs_spread_over_iteration_acc.pdf Delete output/error_vs_spread_over_time_acc.pdf Delete exp_sin_.pdf restore original Project.toml Delete examples/Darcy/darcy_accelerated.jl changed test @info printing, formatting Delete output/ensembles.pdf Delete output/error_vs_spread_over_iteration.pdf Delete output/error_vs_spread_over_time.pdf Delete examples/Darcy/output/data_storage.jld2 Delete examples/Darcy/output/parameter_storage.jld2 fix test file include EKTI test code coverage fixes code cleanup Warning for accelerated EKS process
- Loading branch information
1 parent
15fad65
commit cd0df60
Showing
8 changed files
with
250 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# included in EnsembleKalmanProcess.jl | ||
|
||
export DefaultAccelerator, NesterovAccelerator | ||
export update_state!, set_initial_acceleration! | ||
|
||
""" | ||
$(TYPEDEF) | ||
Default accelerator provides no acceleration, runs traditional EKI | ||
""" | ||
struct DefaultAccelerator <: Accelerator end | ||
|
||
""" | ||
$(TYPEDEF) | ||
Accelerator that adapts Nesterov's momentum method for EKI. | ||
Stores a previous state value u_prev for computational purposes (note this is distinct from state returned as "ensemble value") | ||
$(TYPEDFIELDS) | ||
""" | ||
mutable struct NesterovAccelerator{FT <: AbstractFloat} <: Accelerator | ||
r::FT | ||
u_prev::Any | ||
end | ||
|
||
function NesterovAccelerator(r = 3.0, initial = Float64[]) | ||
return NesterovAccelerator(r, initial) | ||
end | ||
|
||
|
||
""" | ||
Sets u_prev to the initial parameter values | ||
""" | ||
function set_ICs!(accelerator::NesterovAccelerator{FT}, u::MA) where {FT <: AbstractFloat, MA <: AbstractMatrix{FT}} | ||
accelerator.u_prev = u | ||
end | ||
|
||
|
||
""" | ||
Performs traditional state update with no momentum. | ||
""" | ||
function update_state!( | ||
ekp::EnsembleKalmanProcess{FT, IT, P, LRS, DefaultAccelerator}, | ||
u::MA, | ||
) where {FT <: AbstractFloat, IT <: Int, P <: Process, LRS <: LearningRateScheduler, MA <: AbstractMatrix{FT}} | ||
push!(ekp.u, DataContainer(u, data_are_columns = true)) | ||
end | ||
|
||
""" | ||
Performs state update with modified Nesterov momentum approach. | ||
""" | ||
function update_state!( | ||
ekp::EnsembleKalmanProcess{FT, IT, P, LRS, NesterovAccelerator{FT}}, | ||
u::MA, | ||
) where {FT <: AbstractFloat, IT <: Int, P <: Process, LRS <: LearningRateScheduler, MA <: AbstractMatrix{FT}} | ||
## update "v" state: | ||
k = get_N_iterations(ekp) + 2 | ||
v = u .+ (1 - ekp.accelerator.r / k) * (u .- ekp.accelerator.u_prev) | ||
|
||
## update "u" state: | ||
ekp.accelerator.u_prev = u | ||
|
||
## push "v" state to EKP object | ||
push!(ekp.u, DataContainer(v, data_are_columns = true)) | ||
end | ||
|
||
|
||
""" | ||
State update method for UKI with no acceleration. | ||
The Accelerator framework has not yet been integrated with UKI process; | ||
UKI tracks its own states, so this method is empty. | ||
""" | ||
function update_state!( | ||
ekp::EnsembleKalmanProcess{FT, IT, P, LRS, DefaultAccelerator}, | ||
u::MA, | ||
) where {FT <: AbstractFloat, IT <: Int, P <: Unscented, LRS <: LearningRateScheduler, MA <: AbstractMatrix{FT}} | ||
|
||
end | ||
|
||
""" | ||
Placeholder state update method for UKI with Nesterov Accelerator. | ||
The Accelerator framework has not yet been integrated with UKI process, so this | ||
method throws an error. | ||
""" | ||
function update_state!( | ||
ekp::EnsembleKalmanProcess{FT, IT, P, LRS, NesterovAccelerator{FT}}, | ||
u::MA, | ||
) where {FT <: AbstractFloat, IT <: Int, P <: Unscented, LRS <: LearningRateScheduler, MA <: AbstractMatrix{FT}} | ||
throw( | ||
ArgumentError( | ||
"option `accelerator = NesterovAccelerator` is not implemented for UKI, please use `DefaultAccelerator`", | ||
), | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.