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

Disable warnings in vmap or print to stderr #589

Open
joeryjoery opened this issue Apr 17, 2024 · 4 comments
Open

Disable warnings in vmap or print to stderr #589

joeryjoery opened this issue Apr 17, 2024 · 4 comments

Comments

@joeryjoery
Copy link

When running a solver like BFGS or similar, the code runs fine without warnings if I call it directly. But, if I call it inside a vmap then I get spammed by warnings that are not too problematic for my use-case.

I also cannot filter the warnings directly, since the warnings do not print to stderr but to stdout... (at least I think so). I wasn't able to filter the warnings with:

warnings.filterwarnings('ignore', '.*jaxopt.ZoomLineSearch.*')

This is super annoying when logging other information to stdout in my tests, how can I get rid of this?

WARNING: jaxopt.ZoomLineSearch: Very large absolute slope at stepsize=0. (|slope|=0.06082260608673096). The objective is badly conditioned. Consider reparameterizing objective (e.g., normalizing parameters) or finding a better guess for the initial parameters for the solver.
WARNING: jaxopt.ZoomLineSearch: Very large absolute slope at stepsize=0. (|slope|=0.062071025371551514). The objective is badly conditioned. Consider reparameterizing objective (e.g., normalizing parameters) or finding a better guess for the initial parameters for the solver.
WARNING: jaxopt.ZoomLineSearch: Very large absolute slope at stepsize=0. (|slope|=0.05304361507296562). The objective is badly conditioned. Consider reparameterizing objective (e.g., normalizing parameters) or finding a better guess for the initial parameters for the solver.
WARNING: jaxopt.ZoomLineSearch: Cannot even make a step without getting Inf or Nan. The linesearch won't make a step and the optimizer is stuck.
WARNING: jaxopt.ZoomLineSearch: Making an unsafe step, not decreasing enough the objective. Convergence of the solver is compromised as it does not reduce values.
...
@joeryjoery
Copy link
Author

fyi, I found 1 workaround to wrap any call to jaxopt in a context-manager that disables print-statements altogether.

@joeryjoery
Copy link
Author

I just found out that the github version fixed this.

But the version on PyPI does not have the fix for this yet...

@samdeoxys1
Copy link

I'm facing the same issue. Could you be more specific about how you did your workaround? Thank you!

@joeryjoery
Copy link
Author

I'm facing the same issue. Could you be more specific about how you did your workaround? Thank you!

It's been a while since I posted this, but I believe it meant that using pip install jaxopt had the outdated version (with the bug) and that pip install git+https://github.com/google/jaxopt fixed this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants