The code here is based on the paper Autoencoding Variational Bayes by Kingma and Welling (https://arxiv.org/pdf/1312.6114.pdf), and is adapted from GitHub: https://jmetzen.github.io/2015-11-27/vae.html .
- The first step is as always importing the necessary modules. For this recipe we will require Numpy, Matplolib, and TensorFlow:
import numpy as npimport tensorflow as tfimport matplotlib.pyplot as plt%matplotlib inline
- Next, we define the VariationalAutoencoder class. The class __init__ method defines the hyperparameters such as the learning rate, batch size, the placeholders for the input, and the weight and bias variables for the encoder and decoder network. It also builds the computational graph according to the network ...