Skip to Content
Python Deep Learning - Second Edition
book

Python Deep Learning - Second Edition

by Ivan Vasilev, Daniel Slater, Gianmario Spacagna, Peter Roelants, Valentino Zocca
January 2019
Intermediate to advanced
386 pages
11h 13m
English
Packt Publishing
Content preview from Python Deep Learning - Second Edition

Generating new MNIST images with GANs and Keras

In this section, we'll demonstrate how to use GANs to generate new MNIST images with Keras. Let's start:

  1. Do the imports:
import matplotlib.pyplot as pltimport numpy as npfrom keras.datasets import mnistfrom keras.layers import BatchNormalization, Input, Dense, Reshape, Flattenfrom keras.layers.advanced_activations import LeakyReLUfrom keras.models import Sequential, Modelfrom keras.optimizers import Adam
  1. Implement the build_generator function. In this example, we'll use a simple fully-connected generator. However, we'll still follow the guidelines outlined in the DCGAN section:
def build_generator(latent_dim: int):    """    Build discriminator network    :param latent_dim: latent vector size """ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Deep Learning

Python Deep Learning

Valentino Zocca, Gianmario Spacagna, Daniel Slater, Peter Roelants

Publisher Resources

ISBN: 9781789348460Supplemental Content