Normalizing Flows (Inverse AutoRegressive Flows) for stochastic volatility model via advi_minibatch don't work in new PyMC3 version

Hi guys @taku-y, @twiecki (sorry for copying all of you, but I found all of you discussing the question which I have),

I have been checking stochastic volatility model using PyMC3, in particular, applying Normalizing Flows (IAFs), and have come across your discussion and example from here, which doesn’t work anymore in the current PyMC3 version.

In the current PyMC3 (3.7) I don’t have the advi_minibatch functionality. In the example you had, there is a piece:

with model:
    mu, sds, elbo = pm.variational.advi_minibatch(
        n=10000, optimizer=adam, minibatch_tensors=[], minibatches=[], 
        observed_RVs=OrderedDict({r: 1}), local_RVs=OrderedDict(), 
        global_NFs=[iaf1])

As I understood from further discussions, the functionality had migrated to the method pm.Minibatch(); which, however, doesn’t have arguments as global_NFs anymore.

Will be very grateful if you could provide any similar (working) example on how this should be invoked in the current version? Or could the old code be easily translated to the new API?

Will be very grateful for your assistance,

Thanks,
Arthur

Hi Arthur, please check the doc for the official Normalizing Flow API: https://docs.pymc.io/notebooks/normalizing_flows_overview.html

Hi Junpeng,

Thanks a lot for your reply. I came across the NF API, however, I haven’t found the way to use Inverse AutoRegressive Flows. Is there a way to use them?

Will be grateful for any hints.

Thanks,
Arthur

I see, IAF is not currently implemented unfortunately, you can implemented it by inherit it from the flow class: https://github.com/pymc-devs/pymc3/blob/master/pymc3/variational/flows.py

@ferrine do you have some working code using IAF?

No, I don’t have a code example for this