# A question about amortized VI

**URL:** <https://discuss.bayesflow.org/t/a-question-about-amortized-vi/167>\
**Category:** General\
**Created:** [May 27, 2025, 8:47am UTC](https://discuss.bayesflow.org/t/a-question-about-amortized-vi/167 "2025-05-27T08:47:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mingqian.guo](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mingqian.guo](https://discuss.bayesflow.org/u/mingqian.guo)\
**Post date:** [May 27, 2025, 8:47am UTC](https://discuss.bayesflow.org/t/a-question-about-amortized-vi/167/1 "2025-05-27T08:47:23Z")

</div>

Dear Bayesflow developers/Bayesian model experts,

I am start to learn the amortized Bayesian inference. Bayesflow is a wonderful package, but as a stupid person, i always find flow model hard to understand. In the meanwhile, i found VAE very easy to understand and also easy get your hands on.  
I have a question unrelated to the bayesflow which is can we use VAE for amortized inference?In the VAE for amortized inference, the encoder model maximize the posterior probability p(z|x) where the decoder model is basically the data generate model which re-generate the data and compare it with the simulation data.  
I found these papers(Jaffe, P. I., Poldrack, R. A., Schafer, R. J., & Bissett, P. G. (2023). Modelling human behaviour in cognitive tasks with latent dynamical systems. Nature Human Behaviour. [Modelling human behaviour in cognitive tasks with latent dynamical systems | Nature Human Behaviour](https://doi.org/10.1038/s41562-022-01510-8) ;  
Whittington, J. C. R., Muller, T. H., Mark, S., Chen, G., Barry, C., Burgess, N., & Behrens, T. E. J. (2020). The Tolman-Eichenbaum Machine: Unifying Space and Relational Memory through Generalization in the Hippocampal Formation. Cell, 183(5), 1249-1263 e1223. [Redirecting](https://doi.org/10.1016/j.cell.2020.10.024)) used the similar approach for the one-shot model-fitting. Is it a reasonable approach? Thanks a lot.

Best,

---

<div class="post-metadata">

**Author:** ![Jice](https://avatars.discourse-cdn.com/v4/letter/j/c77e96/32.png) [@Jice](https://discuss.bayesflow.org/u/Jice)\
**Post date:** [May 30, 2025, 5:58pm UTC](https://discuss.bayesflow.org/t/a-question-about-amortized-vi/167/2 "2025-05-30T17:58:22Z")

</div>

Hi Mingqian,  
I believe all generative models, including VAEs, have the potential for amortized Bayesian inference. I previously applied a VAE to a two-dimensional parameter space, and it performed reasonably well. However, as many studies, particularly in image generation, have shown, VAEs tend to produce lower-quality samples compared to other generative models. So there are relatively few studies that use VAEs for amortized Bayesian inference.

You may refer to the following paper for more context: [https://arxiv.org/pdf/1909.06296](https://arxiv.org/pdf/1909.06296)

Best,

---

<div class="post-metadata">

**Author:** ![KLDivergence](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.bayesflow.org/kldivergence/32/15_2.png) [@KLDivergence](https://discuss.bayesflow.org/u/KLDivergence)\
**Post date:** [June 2, 2025, 1:07pm UTC](https://discuss.bayesflow.org/t/a-question-about-amortized-vi/167/3 "2025-06-02T13:07:10Z")

</div>

Hi Mingqian,

VAEs amortized inference has a different goal than BayesFlow’s. In VAEs, you learn both the latent variables z and a posterior over latents given data x, p(z \mid x). In BayesFlow (and amortized Bayesian inference), you typically only learn a posterior p(z \mid x), where the “meaning” of the latents is set by the data-generating model (i.e., by yourself as a modeler).
