Generating new MNIST digits with VAE

In this section, we'll see how a VAE can generate new digits for the MNIST dataset and we'll use Keras to do so. We chose MNIST because it will illustrate the generative capabilities of the VAE well. Let's start:

  1. Do the imports:
import matplotlib.pyplot as pltfrom matplotlib.markers import MarkerStyleimport numpy as npfrom keras import backend as Kfrom keras.datasets import mnistfrom keras.layers import Lambda, Input, Densefrom keras.losses import binary_crossentropyfrom keras.models import Model
  1. Instantiate the MNIST dataset (we've already done that):
(x_train, y_train), (x_test, y_test) = mnist.load_data()image_size = x_train.shape[1] * x_train.shape[1]x_train = np.reshape(x_train, [-1, image_size]) ...

Get Python Deep Learning - Second Edition 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.