Amortized inference is an approach to approximate Bayesian inference in which a learned function, usually a neural network, maps each observation directly to the parameters of an approximate posterior distribution, instead of solving a separate optimization or sampling problem for every data point. In probabilistic models with latent variables, it spreads the cost of inference over a one-time training phase, so later queries cost only a single forward pass.
The idea underlies the variational autoencoder, modern simulation-based inference and many deep generative models. Its central trade-off is speed against fidelity: the shared network is fast, but it may produce less accurate posteriors than inference tuned to each data point.
How amortized inference replaces per-datapoint optimization
Amortized inference works by learning the inference procedure itself. In classical variational inference, each observation x receives its own variational parameters, which are optimized separately until the evidence lower bound stops improving. With N observations, that means N independent optimization problems.
An amortized method instead trains an inference network, also called an encoder or recognition model, with shared weights phi. Given x, the network outputs the parameters of q(z | x), for example the mean and variance of a Gaussian. Training maximizes the expected ELBO across the dataset, typically with stochastic gradients and the reparameterization trick.
The table below contrasts the two regimes on the properties that matter most in practice.
| Property | Per-datapoint inference | Amortized inference |
|---|---|---|
| Parameters | One set per observation | One shared network |
| Cost for a new observation | Full optimization run | One forward pass |
| Memory growth | Linear in dataset size | Constant in dataset size |
| Posterior accuracy | Best achievable within the family | Limited by network capacity |
| Generalization | None to unseen data | Applies to new observations |
The amortization gap and the approximation gap
The error of an amortized posterior has two distinct components. The approximation gap arises because the variational family, such as a diagonal Gaussian, cannot represent the true posterior exactly. The amortization gap arises because the shared network does not output the best member of that family for each individual observation.
Both gaps lower the ELBO and bias the learned generative model. Empirical studies of variational autoencoders have found that the amortization gap can dominate when the encoder is small or poorly trained, which means that a richer variational family alone does not fix the problem.
| Error source | Cause | Typical remedy |
|---|---|---|
| Approximation gap | Variational family too simple | Normalizing flows, mixtures, full covariance |
| Amortization gap | Encoder cannot fit each posterior well | Larger encoder, semi-amortized refinement |
| Optimization error | Training stopped early or unstable | Learning rate tuning, warm-up schedules |
| Posterior collapse | Decoder ignores latent variables | KL annealing, free bits, weaker decoder |
Main families of amortized methods
Amortization appears in several branches of probabilistic modeling, from latent variable models to likelihood-free scientific inference. The ideas share a structure, a network trained once and then reused, but they differ in what the network predicts and how it is trained.
| Method | What the network outputs | Typical use |
|---|---|---|
| Helmholtz machine and wake-sleep | Approximate posterior over hidden units | Early unsupervised learning |
| Variational autoencoder | Gaussian posterior parameters | Representation learning, generation |
| Semi-amortized inference | Initialization refined by gradient steps | Reducing the amortization gap |
| Iterative amortized inference | Learned updates to posterior parameters | Sequential and hierarchical models |
| Neural posterior estimation | Conditional density of parameters | Simulation-based scientific inference |
| Amortized importance sampling | Proposal distribution | Probabilistic programming |
In simulation-based inference, the model is a simulator with no tractable likelihood. A conditional density estimator, often a conditional normalizing flow, is trained on simulated pairs of parameters and data and then returns a posterior for real observations within milliseconds.
When amortization pays off in practice
Amortization is worthwhile when many inference queries share one model, so that the training cost is recovered over repeated use. It is less attractive for a single dataset analyzed once, where a dedicated sampler such as Hamiltonian Monte Carlo is often more accurate per unit of effort.
| Situation | Recommended approach | Reason |
|---|---|---|
| Millions of observations, one model | Amortized variational inference | Constant cost per new observation |
| Real-time inference requirement | Amortized encoder | Forward pass fits latency budgets |
| Single dataset, high-stakes estimates | MCMC or per-datapoint VI | Higher posterior accuracy |
| Expensive simulator, many experiments | Neural posterior estimation | Simulation budget is reused |
| Accuracy and speed both critical | Semi-amortized inference | Fast start plus local refinement |
Limitations and failure modes
The most serious limitation is poor behavior outside the training distribution. An encoder trained on one population of observations can return confident but wrong posteriors for unusual inputs, and nothing in a single forward pass signals the failure.
Practitioners therefore treat an amortized posterior as a fast first estimate that must be validated. Common safeguards include comparing a sample of encoder outputs with per-datapoint optimization, measuring the gap between amortized and refined ELBO values, and flagging inputs whose features lie far from the training data. When the gap is large, a few gradient steps started from the encoder output often recover most of the lost accuracy at modest cost.
- Overconfident posteriors: Gaussian encoders often underestimate variance, which weakens uncertainty quantification.
- Miscalibration in simulation-based inference: coverage tests such as simulation-based calibration should be run before trusting results.
- Hidden amortization gap: a good average ELBO can mask poor posteriors for specific data points.
- Retraining cost: any change to the prior or likelihood usually requires training the network again.
A plain-language summary
Many statistical models need to work out hidden causes from what they observe. Doing this from scratch for every new observation is slow.
Amortized inference trains a network once to make that guess instantly. It is like an experienced doctor who has seen thousands of patients. The doctor does not run a new study for each patient. Years of practice let the doctor form a good first judgment in seconds.
The price is that quick guesses are sometimes less precise. Careful checking still matters for unusual cases.
An example from practice
An astrophysics team studies gravitational-wave signals from merging black holes. Their physical simulator produces realistic signals, but estimating the masses and spins behind one real detection with standard sampling can take many hours of computation.
The team generates several million simulated signals with known parameters and trains a conditional normalizing flow that maps a signal to a posterior over the source parameters. Training takes several days on GPUs. After that, each new detection receives a full posterior in well under a minute.
Before relying on the network, the team runs calibration tests on held-out simulations and compares selected events with a traditional sampler. The result is rapid parameter estimates for alerts to telescope operators, with slower reference analyses reserved for the most unusual events.