Skip to content
Discussion options

You must be logged in to vote

Hi @zhihanyang2022 👋

An IAF is the same as a MAF, but with reversed transformations, such that sampling is fast and log-prob is slow. In Zuko, you can transform any flow to an inverse flow with the following pattern:

maf = zuko.flows.MAF(features=2, transforms=3, hidden_features=(64, 64))  # or NSF, NAF, ...
iaf = zuko.flows.Flow(flow.transform.inv, flow.base)

We use this pattern in the "train from energy" tutorial.

https://zuko.readthedocs.io/stable/tutorials/reverse_kl.html

Please note that to optimize through the sampling, you need to call rsample (or rsample_and_log_prob) instead of sample.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by francois-rozet
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #71 on October 12, 2025 19:59.