google / jaxopt

Hardware accelerated, batchable and differentiable optimizers in JAX.
https://jaxopt.github.io
Apache License 2.0
919 stars 64 forks source link

trust-ncg in ScipyMinimize argument issue #240

Open hanzy1110 opened 2 years ago

hanzy1110 commented 2 years ago

Hi! I've been trying to use the scipy wrapper for the trust-ncg method. When I do this, I'm prompted to pass the hessian vector product as an argument. The source code for the _run method is as follows (from the documentation): res = osp.optimize.minimize(scipy_fun, jnp_to_onp(init_params, self.dtype), jac=True, bounds=bounds, method=self.method, options=self.options) Which doesn't allow the hess argument to be passed to scipy. indeed when I pass the hess argument inside options I get an exception telling me scipy has received hess twice and when I don't pass it the resulting exception tells me that I haven't specified the hessian.

mblondel commented 2 years ago

Thanks for the bug report. When trust-ncg is used, we should provide the Hessian vector product automatically for the user.

CC @fllinares

ignacio-rh commented 2 years ago

Just adding that I hit this bug as well. Couldn't figure out a way to pass the hessian.

Edit: And just want to say thank you for the awesome library - its so incredibly fast and easy to use!