Repository navigation
Fixes current density estimator bug - #1155
Merged
manuelgloeckler merged 2 commits intoMay 7, 2024
Merged
manuelgloeckler merged 2 commits into
manuelgloeckler merged 2 commits into
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1155 +/- ##
==========================================
- Coverage 83.93% 74.23% -9.71%
==========================================
Files 90 90
Lines 6930 6931 +1
==========================================
- Hits 5817 5145 -672
- Misses 1113 1786 +673
Flags with carried forward coverage won't be shown. Click here to find out more.
|
michaeldeistler
approved these changes
May 7, 2024
| *sample_shape, | ||
| condition_batch_dim, | ||
| ) | ||
| + self.input_shape |
Contributor
There was a problem hiding this comment.
thanks! Would
(*sample_shape, condition_batch_dim, *self.input_shape)also work? It's just a bit cleaner IMO.
Contributor
Author
|
Added tests that check if batched log_prob/sample will be the same as unbatched. Will merge after tests passed. |
dgedon
added a commit
that referenced
this pull request
Nov 23, 2026
…d and unconditional estimator defaults (#2158) * fix(estimators): keep nflows sample_and_log_prob samples with their condition nflows returns samples and log probs as (batch, sample). `sample_and_log_prob` reshaped them without the transpose that `sample()` got in #1155, so with several conditions it filed half of the samples and their log probs under the wrong condition. The #1155 test now also checks `sample_and_log_prob` against `log_prob`. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(estimators): use self.net in the unconditional density estimator base `UnconditionalDensityEstimator.log_prob` and `sample` used `self._neural_net`, which is never set, so subclasses that keep these methods raised an AttributeError. They now use `self.net` and keep the `eval()` call from #1470. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(samplers): thin serial slice_np chains once `SliceSamplerSerial.run(n)` built each chain's `SliceSampler` with `thin`, which already takes `thin` steps per kept sample, and then thinned the result again. With `thin > 1` this cost `thin` times more potential evaluations and kept every `thin**2`-th step. The chain sampler now uses `thin=1`, so `run(n)` takes `n` steps and thins once, as `SliceSamplerVectorized` does. Seeded `slice_np` results with `thin > 1` change. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(posteriors): make mcmc_method and set_mcmc_method set the sampling method `MCMCPosterior.mcmc_method` read `self._mcmc_method`, which `__init__` never sets, and `set_mcmc_method` wrote that attribute while sampling reads `self.method`. So the getter raised, and after setting a method the posterior reported it but kept sampling with the old one. Both now use `self.method`, and `set_mcmc_method` raises for unknown methods, as `__init__` does. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(estimators): leave train/eval mode to the caller in unconditional log_prob `UnconditionalDensityEstimator.log_prob` called `self.net.eval()`, so a subclass whose `loss` uses `log_prob` was trained with Dropout and BatchNorm in eval mode. The trainer sets the mode, as for the other estimators. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor: type set_mcmc_method as MCMCPosterior, reshape as in sample() `set_mcmc_method` returns the posterior itself, so its signature and docstring now say `MCMCPosterior` and type checkers follow chained calls. `NFlowsFlow.sample_and_log_prob` reshapes samples to `self.input_shape`, as `sample()` does; the shapes are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix? Explain your changes
Fixes #1154
TODO