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

Accessing optimization iteration in callback function #617

Closed
jClugstor opened this issue Oct 23, 2023 · 5 comments
Closed

Accessing optimization iteration in callback function #617

jClugstor opened this issue Oct 23, 2023 · 5 comments

Comments

@jClugstor
Copy link

Is there a way that I could get the current iteration of the optimization inside of a callback. I would like to be able to access the number of times the loss function has been called from inside of the callback function.

@Vaibhavdixit02
Copy link
Member

It should be available from the iter field of the OptimizationState https://docs.sciml.ai/Optimization/stable/API/optimization_state/#optstate which is the first argument to the callback

@SebastianM-C
Copy link
Contributor

For the number of calls to the loss function, the .original filed would be useful? The number of iterations would be a lower bound on that number.

@Vaibhavdixit02
Copy link
Member

Yeah, that's used to populate the fevals field in https://docs.sciml.ai/Optimization/stable/API/optimization_stats/ for some solvers if they return it. We might switch to an Optimization.jl native counter if it makes sense later.

@jClugstor
Copy link
Author

Did the first argument to the callback recently change to be an OptimizationState?

@jClugstor
Copy link
Author

I see, #649 did it, I think that solves it then, thanks!

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

3 participants