How to do it...

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 .

  1. 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
  1. 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 ...

Get TensorFlow 1.x Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.