sbi icon indicating copy to clipboard operation
sbi copied to clipboard

Add interface for Zuko density estimators 🔥

Open janfb opened this issue 1 year ago • 1 comments

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 NflowsFlow is used in our API (see tests): https://github.com/sbi-dev/sbi/blob/17f3033aa55514ac6c039da729ee84ce32eb20d9/tests/density_estimator_test.py#L47-L61
  • Check out how Zuko flows are used in the lampe API: https://github.com/probabilists/lampe/blob/3e88c8e101e55b5689209470e60ddcb4e4962d1d/lampe/inference/npe.py#L71 This is how one could compute the loss for the DensityEstimator API (should be agnostic to x vs theta).
  • implement ZukoFlows as new density estimator interface
  • add tests in density_estimator_test.py

janfb avatar Mar 04 '24 13:03 janfb

ZukoFlow is now available as a subclass of DensityEstimator, along with an example builder function build_zuko_maf!

Would now be good to add different flow types supported by Zuko following this structure (along with api tests).

gmoss13 avatar Mar 13 '24 19:03 gmoss13

It seems like some work has begun here? I will add myself to help continue the integration.

bkmi avatar Mar 18 '24 09:03 bkmi

I would also like to add myself to help continue the integration with Zuko!

anastasiakrouglova avatar Mar 18 '24 10:03 anastasiakrouglova

solved via #1116

janfb avatar Apr 09 '24 07:04 janfb