Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Generative Adversarial Networks with Keras

You're reading from   Hands-On Generative Adversarial Networks with Keras Your guide to implementing next-generation generative adversarial networks

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781789538205
Length 272 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Rafael Valle Rafael Valle
Author Profile Icon Rafael Valle
Rafael Valle
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Section 1: Introduction and Environment Setup FREE CHAPTER
2. Deep Learning Basics and Environment Setup 3. Introduction to Generative Models 4. Section 2: Training GANs
5. Implementing Your First GAN 6. Evaluating Your First GAN 7. Improving Your First GAN 8. Section 3: Application of GANs in Computer Vision, Natural Language Processing, and Audio
9. Progressive Growing of GANs 10. Generation of Discrete Sequences Using GANs 11. Text-to-Image Synthesis with GANs 12. TequilaGAN - Identifying GAN Samples 13. Whats next in GANs

Auxiliary functions

We are going to use three auxiliary functions to get the data, plot the images, and plot the losses.

The function to get the data uses the Keras cifar10 class, converts it to fp32, 32-bit floating point, and scales it to [-1, 1]. Scaling images to [-1, 1] is a common practice when training GANs on image data that bounds the range of the output, possibly avoiding explosions:

def get_data():
# load cifar10 data
(X_train, y_train), (X_test, y_test) = cifar10.load_data()

# convert train and test data to float32
X_train = X_train.astype(np.float32)
X_test = X_test.astype(np.float32)

# scale train and test data to [-1, 1]
X_train = (X_train / 255) * 2 - 1
X_test = (X_train / 255) * 2 - 1

return X_train, X_test

The method below is used to plot a grid with images. It takes a tensor with the images and the full path where the image...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image