You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Amortized VI fails at the first iteration with a bounded prior #2137
VIPosterior.train_amortized() stops at iteration 0 with a non-finite loss when the prior is a BoxUniform. The same setup with a Gaussian prior trains. It happens with NLE, NRE and NPE potentials. The amortized VI tests use Gaussian priors only, so CI does not catch it.
prior=BoxUniform(-3*torch.ones(2), 3*torch.ones(2))
theta=prior.sample((300,))
x=theta+0.3*torch.randn_like(theta)
nle=NLE(prior)
nle.append_simulations(theta, x).train(max_num_epochs=3)
posterior=nle.build_posterior(sample_with="vi")
posterior.train_amortized(theta, x, max_num_iters=5)
# RuntimeError: Training loss became non-finite at iteration 0: inf.
I think the conditional flow of amortized VI draws theta outside the support of the prior, where the potential is -inf. Single-x VI maps its flow through the support transform of the prior; amortized VI probably needs the same. A fix should come with a test that uses a bounded prior.
Activity