Generating images using VAEs
From Chapter 4, Deep Learning for IOT, you should be familiar with autoencoders and their functions. VAEs are a type of autoencoder; here, we retain the (trained) Decoder part, which can be used by feeding random latent features z to generate data similar to the training data. Now, if you remember, in autoencoders, the Encoder results in the generation of low-dimensional features, z:
![](https://static.packt-cdn.com/products/9781788836067/graphics/3705300e-2946-40ed-857f-71543e49bbca.png)
The architecture of autoencoders
The VAEs are concerned with finding the likelihood function p(x) from the latent features z:Â
![](https://static.packt-cdn.com/products/9781788836067/graphics/b8a6bbc8-694e-4965-9d9d-6fbc414f0082.png)
This is an intractable density function, and it isn't possible to directly optimize it; instead, we obtain a lower bound by using a simple Gaussian prior p(z) and making both Encoder and Decoder networks probabilistic:
![](https://static.packt-cdn.com/products/9781788836067/graphics/b205c070-6728-46fe-9cbf-a8af6e6218c1.png)
 Architecture of a VAE
This allows us to define a tractable lower bound on the log likelihood, given by the following:
![](https://static.packt-cdn.com/products/9781788836067/graphics/491c9734-cfe4-4f8a-93e6-01e7fca31cae.png)
In the preceding, θ represents the decoder network parameters and φ the encoder network parameters. The network is trained by maximizing...