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
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Practical Convolutional Neural Networks

You're reading from   Practical Convolutional Neural Networks Implement advanced deep learning models using Python

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781788392303
Length 218 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Mohit Sewak Mohit Sewak
Author Profile Icon Mohit Sewak
Mohit Sewak
Md. Rezaul Karim Md. Rezaul Karim
Author Profile Icon Md. Rezaul Karim
Md. Rezaul Karim
Pradeep Pujari Pradeep Pujari
Author Profile Icon Pradeep Pujari
Pradeep Pujari
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Deep Neural Networks – Overview FREE CHAPTER 2. Introduction to Convolutional Neural Networks 3. Build Your First CNN and Performance Optimization 4. Popular CNN Model Architectures 5. Transfer Learning 6. Autoencoders for CNN 7. Object Detection and Instance Segmentation with CNN 8. GAN: Generating New Images with CNN 9. Attention Mechanism for CNN and Visual Models 10. Other Books You May Enjoy

GAN – code example


In the following example, we build and train a GAN model using an MNIST dataset and using TensorFlow. Here, we will use a special version of the ReLU activation function known as Leaky ReLU. The output is a new type of handwritten digit:

Note

Leaky ReLU is a variation of the ReLU activation function given by the formula f(xmax(αx,x). So the output for the negative value for x is alpha * x and the output for positive x is x.

#import all necessary libraries and load data set
%matplotlib inline

import pickle as pkl
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data')

In order to build this network, we need two inputs, one for the generator and one for the discriminator. In the following code, we create placeholders for real_input for the discriminator and z_input for the generator, with the input sizes as dim_real and dim_z, respectively:

#place...
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