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

[BUGFIX] grad_2f1: Add minimum number of iterations and early stopping test #2858

Merged
merged 2 commits into from
May 19, 2023
Merged

[BUGFIX] grad_2f1: Add minimum number of iterations and early stopping test #2858

merged 2 commits into from
May 19, 2023

Conversation

andrjohns
Copy link
Collaborator

Summary

As mentioned in #2857, the grad_2f1 function can falsely converge early when only calculating gradients w.r.t. a subset of parameters. This PR introduces a minimum number of iterations (5) to avoid this and a test to verify

Tests

Test-case from #2857 added

Side Effects

N/A

Release notes

Added a minimum number of iterations (5) to the grad_2f1 function to avoid early convergence

Checklist

@andrjohns
Copy link
Collaborator Author

@spinkney would you be able to have a look at this? Do you think 5 iterations is enough or should we go for 10?

@andrjohns andrjohns added the bug label Jan 2, 2023
@andrjohns andrjohns changed the title grad_2f1: Add minimum number of iterations and early stopping test [BUGFIX] grad_2f1: Add minimum number of iterations and early stopping test Jan 2, 2023
@ricardoV94
Copy link

ricardoV94 commented Jan 2, 2023

@spinkney would you be able to have a look at this? Do you think 5 iterations is enough or should we go for 10?

I used 10 when adapting your code here pymc-devs/pytensor#90

I am using the same test cases you guys had, but the algorithm always computes one partial derivative at a time. With 5 minimum iterations the tests wouldn't all pass, but I am not sure I am asserting the same precision as the STAN tests.

It feels pretty arbitrary regardless :)

Copy link
Member

@syclik syclik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrjohns, just asking for a change for readability. I don't think it's worth adding it to the signature.

I think it'd be ok bumping it up to 10 if you want. Or leaving it at 5. It is pretty arbitrary at this point.

stan/math/prim/fun/grad_2F1.hpp Outdated Show resolved Hide resolved
@spinkney
Copy link
Collaborator

spinkney commented Jan 9, 2023

@spinkney would you be able to have a look at this? Do you think 5 iterations is enough or should we go for 10?

I think 10 is better. Is there any way you can do a grid search across possible values to see if there is a problematic range where even 10 iterations is not enough? If you can't find any ranges that's fine. If you do find a problematic range then we can document it and see what else we can do (more iterations or notes to future devs to improve the algorithm in that range).

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

Successfully merging this pull request may close these issues.

4 participants