def test_vae_automatically_finds_kl_integrator():
 encoding_model = MLP(layers=[Linear(layer_name='h', dim=10, irange=0.01)])
 decoding_model = MLP(layers=[Linear(layer_name='h', dim=10, irange=0.01)])
 prior = DiagonalGaussianPrior()
 conditional = BernoulliVector(mlp=decoding_model, name='conditional')
 posterior = DiagonalGaussian(mlp=encoding_model, name='posterior')
 vae = VAE(nvis=10, prior=prior, conditional=conditional, posterior=posterior, nhid=5)
 assert ((vae.kl_integrator is not None) and isinstance(vae.kl_integrator, DiagonalGaussianPriorPosteriorKL))

def test_vae_automatically_finds_kl_integrator ( ) : encoding_model = MLP ( layers = [ Linear ( layer_name = 'h' , dim = 10 , irange = 0.01 ) ] ) decoding_model = MLP ( layers = [ Linear ( layer_name = 'h' , dim = 10 , irange = 0.01 ) ] ) prior = DiagonalGaussianPrior ( ) conditional = BernoulliVector ( mlp = decoding_model , name = 'conditional' ) posterior = DiagonalGaussian ( mlp = encoding_model , name = 'posterior' ) vae = VAE ( nvis = 10 , prior = prior , conditional = conditional , posterior = posterior , nhid = 5 ) assert ( ( vae . kl_integrator is not None ) and isinstance ( vae . kl_integrator , DiagonalGaussianPriorPosteriorKL ) )
vae automatically finds the right klintegrator .