Comments (3)
Hi all, thanks for the phenomenal library. We're already using it in several statistical genetics methods in my group!
That's great to hear, thank you!
On HVPs: if I understand you correctly, this is a general JAX question, rather than specifically a question of how to integrate a solve into Optimistix? You're looking to get both the gradient and a HVP without having to treat them both separately (which would be 3 sweeps in total).
This approach will get you 2 sweeps, which I think is optimal:
def to_jvp(x):
return jax.value_and_grad(fn)(x)
(f, dfdxi), (_, dfdxidxjvj) = jax.jvp(to_jvp, (x,), (v,))
from optimistix.
Newton CG is one of the algorithms which I think could be somewhat involved to implement. It is further from the existing solvers in Optimistix, so there's more custom work that needs to be done to get it running.
There's two steps I would take if I were implementing it (which I may in the future):
- Implement a custom top-level solver which passes the Hessian-vector product
$h(v) = \nabla^2 f(x)$ vialx.FunctionLinearOperator
inFunctionInfo.EvalGradHessian
. Take a look at the abstract solvers (AbstractGradientDescent
,AbstractGaussNewton
,AbstractBFGS
, etc.) for a bit on how to do this, and check out the docs forFunctionInfo
. Implementing a top-level solver from scratch for the first time can be a little tricky, because it requires touching all of the abstractions used in Optimistix. However, the technical bit should be very simple here. If you find it difficult to figure out from looking at existing implementations just poke me! - Implement an early-exit version of CG in Lineax. This is needed because for inexact Newton CG the CG iterates stop immediately if a direction of negative curvature is encountered, allowing non-psd matrices to be approximately solved with CG. This should be straightforward, copy the code from the implementation of CG in Lineax and add the curvature condition to the function
not_converged
(something liketree_dot(y, operator.mv(y)) > 0
. This may need tweaking, and you'll also have to disable the positive semidefinite checks.)
This should be pretty much everything though. Just use optx.NewtonDescent
with linear_solver=NewEarlyExitCG
for the descent, and your favorite Optimistix Search
for the search and it should all work! You could probably use some other descents as well, such as DoglegDescent
or DampedNewtonDescent
by passing the new linear solver in to these descents. I don't know how well these would work, as they're not standard algorithms (neat!)
from optimistix.
Yes exactly! It isn't clear to me how to work this into a Newton-like CG solver, but I'll keep toying around. Thanks as always for your enthusiasm and detailed help. It is greatly appreciated!
from optimistix.
Related Issues (20)
- Can't use Optimistix solvers with `eqx.Module`s and filtered transformations HOT 2
- BestSoFarMinimiser behavior HOT 1
- correct name of the exception class that Equinox uses for runtime errors HOT 1
- Error in "optimistix/docs/examples /optimise_diffeq.ipynb" HOT 1
- Issue with vmap `optx.least_squares`. HOT 2
- grad of vmap of function which wraps an optax solver occasionally fails HOT 2
- `BestSoFar...` wanted behavior ? HOT 1
- Classical newton methods HOT 6
- Non-finite values in the root function are not handled well HOT 2
- Will constrained optimization be supported? HOT 4
- Behavior of BFGS HOT 2
- pytree output structure mismatch error in backprop during vmap HOT 9
- Incompatibility of least_squares and custom_vjp HOT 2
- Extracting intermediate function values/ losses from the solve HOT 4
- Zero implicit gradients when using `ImplicitAdjoint` with CG solver HOT 4
- Would an exhaustive grid search have a place in `optimistix`? HOT 2
- Using `optimistix` with an `equinox` model HOT 2
- Incompatibility with jax 0.4.27 HOT 1
- Possibly of interest HOT 1
- Unexpected behaviour with JAX version HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from optimistix.