January 2019
Intermediate to advanced
386 pages
11h 13m
English
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:
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
(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]) ...