Repository navigation
Closed
Labels
architectureInternal structure and design of the codebasebeginner friendlyGood for newcomersenhancementImprovement planned or wanted by the maintainersestimatorsNeural density estimators and the neural_nets modulehackathonFor our in-person hackathons with maintainers present, not a general up-for-grabs list
Milestone
Description
Is your feature request related to a problem? Please describe.
Given the new DensityEstimator setup (#952 , #965) we can now start implementing new density estimators.
Describe the solution you'd like
For example: analog to the NflowsFlow class there could be a class for Zuko flows. Such a class needs to inherit from DensityEstimator and implements its methods. For Zuko flows, most of them are there already, but not all. E.g., the loss needs to implemented, and the condition_shape needs to be passed at init.
Additional context, plan:
- Have a look at how the
NflowsFlowis used in our API (see tests):
sbi/tests/density_estimator_test.py
Lines 47 to 61 in 17f3033
net = build_nsf( batch_input, batch_context, hidden_features=10, num_transforms=2, embedding_net=EmbeddingNet(), ) estimator = density_estimator(net, condition_shape) # Loss is only required to work for batched inputs and contexts loss = estimator.loss(batch_input, batch_context) assert loss.shape == ( nsamples, ), f"Loss shape is not correct. It is of shape {loss.shape}, but should \ be {(nsamples, )}" - Check out how
Zukoflows are used in thelampeAPI: https://github.com/probabilists/lampe/blob/3e88c8e101e55b5689209470e60ddcb4e4962d1d/lampe/inference/npe.py#L71
This is how one could compute the loss for theDensityEstimatorAPI (should be agnostic toxvstheta). - implement
ZukoFlowsas new density estimator interface - add tests in
density_estimator_test.py
Metadata
Metadata
Assignees
Labels
architectureInternal structure and design of the codebasebeginner friendlyGood for newcomersenhancementImprovement planned or wanted by the maintainersestimatorsNeural density estimators and the neural_nets modulehackathonFor our in-person hackathons with maintainers present, not a general up-for-grabs list
Activity
gmoss13 commentedon Mar 13, 2024
ZukoFlowis now available as a subclass ofDensityEstimator, along with an example builder functionbuild_zuko_maf!Would now be good to add different flow types supported by Zuko following this structure (along with api tests).
bkmi commentedon Mar 18, 2024
It seems like some work has begun here? I will add myself to help continue the integration.
anastasiakrouglova commentedon Mar 18, 2024
I would also like to add myself to help continue the integration with Zuko!
janfb commentedon Apr 9, 2024
solved via #1116