ReactiveBayes / RxInfer.jl

Julia package for automated Bayesian inference on a factor graph with reactive message passing
MIT License
254 stars 24 forks source link

feat: allow to halt iterations based on callback return value #85

Closed bvdmitri closed 1 year ago

bvdmitri commented 1 year ago

This PR fixes #84. @John-Boik

After this PR it is possible to return a true/false value from the before_iteration/after_iteration callbacks. true value indicates that the inference procedure should be halted and no further inference should be performed.

The solution here is not ideal. Ideally we should support different "convergence" strategies, e.g based on BFE values. I like the proposal from @John-Boik in the #84, but I believe it must be a separate issue. For now I believe its fine to use callbacks that allow to halt iterations based on true/false.

bvdmitri commented 1 year ago

@albertpod ping

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 91.30% and project coverage change: +0.40 :tada:

Comparison is base (8a89b44) 79.88% compared to head (94babb1) 80.28%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #85 +/- ## ========================================== + Coverage 79.88% 80.28% +0.40% ========================================== Files 11 11 Lines 1173 1182 +9 ========================================== + Hits 937 949 +12 + Misses 236 233 -3 ``` | [Impacted Files](https://codecov.io/gh/biaslab/RxInfer.jl/pull/85?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=biaslab) | Coverage Δ | | |---|---|---| | [src/score/actor.jl](https://codecov.io/gh/biaslab/RxInfer.jl/pull/85?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=biaslab#diff-c3JjL3Njb3JlL2FjdG9yLmps) | `83.33% <87.50%> (-0.99%)` | :arrow_down: | | [src/inference.jl](https://codecov.io/gh/biaslab/RxInfer.jl/pull/85?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=biaslab#diff-c3JjL2luZmVyZW5jZS5qbA==) | `75.76% <92.30%> (+0.96%)` | :arrow_up: | | [src/helpers.jl](https://codecov.io/gh/biaslab/RxInfer.jl/pull/85?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=biaslab#diff-c3JjL2hlbHBlcnMuamw=) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=biaslab). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=biaslab)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

bvdmitri commented 1 year ago

The before/after_iteration existed before and their purpose is not necessarily to halt the iterations. Previously, they only allowed to do some extra actions (e.g. logging execution), but now they also allow to halt.