Skip to contents

ELBO = E_q[log p(x|z)] - beta KL, both terms divided by the batch size; the KL is the closed form.

Usage

morie_geron_vae_elbo(x, mu, logvar, recon, likelihood = "gaussian", beta = 1)

Arguments

x

Input batch.

mu, logvar

Encoder outputs.

recon

Decoder output.

likelihood

"gaussian" or "bernoulli".

beta

Non-negative KL weight.

Value

List with elbo, loss, reconstruction_term, kl, kl_per_dim.

Examples

morie_geron_vae_elbo(x = c(1, 2, 3, 4, 5, 6, 7, 8), mu = c(1, 2, 3, 4, 5, 6, 7, 8),
  logvar = c(1, 2, 3, 4, 5, 6, 7, 8), recon = c(1, 2, 3, 4, 5, 6, 7, 8))
#> $elbo
#> [1] -2437.112
#> 
#> $loss
#> [1] 2437.112
#> 
#> $reconstruction_term
#> [1] 0
#> 
#> $kl
#> [1] 2437.112
#> 
#> $kl_per_dim
#> [1]    0.8591409    4.1945280   12.5427685   32.7990750   83.7065796
#> [6]  216.2143967  568.8165792 1517.9789935
#> 
#> $beta
#> [1] 1
#> 
#> $estimate
#> [1] -2437.112
#> 
#> $n
#> [1] 1
#>