Repository navigation
Add solver-in-the-loop active learning example with neojax - #113
Open
paulgekeler wants to merge 1 commit into
Open
paulgekeler wants to merge 1 commit into
paulgekeler wants to merge 1 commit into
Conversation
Author
|
Please make any changes you'd like. We can also change the example to something completely different if need be. |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new example in the
Advancedsection as discussed in #65. The example experiments with a solver-in-the-loop active learning approach based on exponax and neojax. This is something I wanted to try for a while and exponax speed makes it possible because the solver overhead is negligible compared to training time.The underlying PDEs are the 2D Navier-Stokes equations on a periodic, unit-square domain. We try to learn a surrogate for the solution operator
where$\omega$ is the vorticity, $A \in [0.5, 10.0]$ the amplitude of the initial vorticity $\omega(\cdot,0) = As$ , where $s$ is a random smooth field and $\nu$ with $\text{log}_{10}(\nu) \in [-4.0, -2.5]$ the viscosity. The operator thus maps the shape of the initial condition and the parameters to the vorticity at the final time $T$ .
The parameters are chosen such that a small learnable part of the parameter space has a high Reynolds number and is therefore harder to learn but still learnable. Ideally, uncertainty-based sample acquisition queries more in this subspace than random acquisition.
We create an ensemble of 5 CNOs (leveraging$L^2$ error and the number of seen simulations.
vmapover constructor) in neojax and pretrain it on 128 simulations created with exponax forWARMUP_EPOCHS(default 60). Then forN_ROUNDS(default 6) refinement rounds, we draw candidate initial conditions and parameters (either random or uncertainty-based), query the exponax solver to solve for these ics and params (N_QUERYsamples) and fine-tune the ensemble using the created (input, solution) pairs. We then compare how uncertainty-based acquisition compares to random acquisition w.r.t. relativeBecause exponax is so fast, the solver-in-the-loop has little overhead over pure ensemble training. The example highlights this by logging solver and training timings at intervals.
The runs are repeated across 3 seeds to check for repeatability.
Notes
I didn't want to edit the dependencies without checking first and there are no example dependencies so the first cell
pipinstalls"neojax-operators[ex]"andexponax.Checks
mkdocs build succeeded (raised warnings unrelated to this PR:
traitletsdependency, unused other notebooks)Additions
active_learning.ipynbunderdocs/examples/active_learning.ipynb