bayesflow-org / bayesflow

A Python library for amortized Bayesian workflows using generative neural networks.
https://bayesflow.org/
MIT License
372 stars 52 forks source link

Data adapter: Keep track of the jacobian for variable transforms #245

Open Kucharssim opened 6 days ago

Kucharssim commented 6 days ago

Given that the data adapter is now used for variable transforms (for e.g., implementing parameter constraints or scaling), it would be nice to keep track of the jacobian of the transform, so that if the user wants to use the log_prob method, it is possible to automatically obtain the log prob on the "constrained/data space" instead of the "unconstrained/network space".

For custom transforms, the user would have to supply corresponding log_det_jacobian function, but of course that should be only optional to those cases where the user wants to use log_prob in the first place.

I know we talked about this with @LarsKue and @paul-buerkner already at different time points, just making it an issue so that we can keep track of it here.

stefanradev93 commented 5 days ago

Hi Simon, I like the idea! Would you like to try a draft implementation a few pull requests down the line?

Kucharssim commented 2 days ago

Sure, I can give it a go :)