Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
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 (15) Chapters Close

Preface
Who this book is for
What this book covers
To get the most out of this book
Get in touch
1. Deep Learning Basics and Environment Setup FREE CHAPTER 2. Introduction to Generative Models 3. Implementing Your First GAN 4. Evaluating Your First GAN 5. Improving Your First GAN 6. Progressive Growing of GANs 7. Generation of Discrete Sequences Using GANs 8. Text-to-Image Synthesis with GANs 9. TequilaGAN - Identifying GAN Samples 10. Whats next in GANs

Deep learning environment setup

In this section, we will provide instructions on how to set up a Python deep learning programming environment that will be used throughout the book. We will start with Anaconda, which makes package management and deployment easy, and NVIDIA's CUDA Toolkit and cuDNN, which make training and inference in deep learning models quick. There are several compute cloud services, like Amazon Web Services (AWS), that provide ready to use deep learning environments with NVIDIA GPUs.

Installing Anaconda and Python

Anaconda is a free and open source efficient distribution that provides easy package management and deployment for the programming languages R and Python. Anaconda focuses on data science and deep learning applications and provides over 6 million users with hundreds of packages and support for Windows, Linux, and macOS.

Installing Anaconda is easy and simply requires downloading the installation wizard for a target Python version. We are going to download Anaconda's installation wizard for Python 3.5. The installation wizard can be downloaded on Anaconda's website at https://www.anaconda.com/download/.

After following the wizard instructions and installing Anaconda, we are going to update all Anaconda packages using the conda command. To do so, open Anaconda's Command-Line Interface (CLI) and type the following commands:

conda update conda
conda update –all

Setting up a virtual environment in Anaconda

A virtual environment allows us to have different versions of libraries and executables, avoiding conflicts between them and making it easy to develop multiple projects at the same time. Creating a virtual environment in Anaconda is easy and only requires executing a single command on Anaconda's CLI. With the following command, we are going to create a virtual environment running Python 3.5 and name it deeplearning:

conda create -n deeplearning pip python=3.5

Now that we have created the deeplearning virtual environment, we are going to activate it so that we can start populating it with Python packages. To do so, open Anaconda's CLI and type the following command:

activate deeplearning

After typing this command, your CLI prompt should change and include a prefix to indicate that the virtual environment is currently active.

Installing TensorFlow

TensorFlow is a high-level deep learning API written in Python and developed by Google. In this book, TensorFlow will be the backend that supports Keras, our main deep learning API. Follow instructions on the following website: https://www.tensorflow.org/install/install_linux#tensorflow_gpu_support. Choose your OS, and install TensorFlow for Python 3.5 with GPU support.

Installing Keras

Keras is a high-level deep learning API written in Python that supports TensorFlow, CNTK, and Theano as backends. Keras has the main building blocks for building, training, and prototyping deep learning projects. The building blocks in Keras include neural network layers, optimization functions, activation functions, and several tools for working with data and training in general.

Installing keras is easy! Inside our deeplearning virtual environment, type the following command:

pip install keras

Installing data visualization and machine learning libraries

In addition to Keras, the main deep learning library used in this book, we are going to install libraries for data visualization and machine learning in general. These libraries provide valuable tools to help developers easily build training pipelines, evaluate and train models more efficiently, and visualize data quickly and effortlessly.

Although there are distributions like Anaconda that provide environments with such libraries already installed by default, we describe the installation procedures here such that the reader learns the process and does not become dependent on pre-packaged third party distributions.

The matplotlib library

The most widely used data visualization library in Python is called matplotlib. It enables the quick and easy creation of publication-quality complex plots and graphs, which facilitate understanding data. Matploblib can be installed with pip as follows:

pip install matplotlib

The Jupyter library

Jupyter is another widely used and valuable Python library. It includes Jupyter notebooks, which allow interactive and quick prototyping in Python and other languages on the browser. Jupyter also supports data visualization, including images, video, and audio! Jupyter notebooks can be shared and accessed via a web browser. Jupyter can be installed with pip as follows:

pip install jupyter

The scikit-learn library

Scikit-learn is the leading Python library for machine learning and data science in general. Scikit-learn is open source and built on top of NumPy, SciPy, and matplotlib. It contains a wide range of machine learning models and algorithms, including classification, regression, clustering, dimensionality reduction, model selection, data preprocessing, metrics, and many other valuable things. Scikit-learn can be installed with pip as follows:

pip install sklearn

Now that we have installed our libraries, it is time to make sure everything works as expected.

NVIDIA's CUDA Toolkit and cuDNN

NVIDIA's CUDA Toolkit provides a development environment for creating high-performance GPU-accelerated applications. You can develop, optimize, and deploy your applications on GPU-accelerated embedded systems, workstations, enterprise data centers, cloud-based platforms, and HPC supercomputers using the CUDA Toolkit. The Toolkit includes GPU-accelerated libraries, debugging and optimization tools, a C/C++ compiler, and a runtime library to deploy your application.

Installing the CUDA Toolkit is easy and can be downloaded from https://developer.nvidia.com/cuda-downloads.

NVIDIA's cuDNN is a GPU-accelerated library of primitives for deep neural networks. cuDNN provides highly-tuned implementations for standard routines such as forward and backward convolution, pooling, normalization, and activation layers. cuDNN is part of the NVIDIA Deep Learning SDK.

cuDNN is available for members of the NVIDIA Developer Program. Registration to this program is free and members are given access to the latest NVIDIA SDKs and tools to accelerate building applications in key technology areas such as artificial intelligence, deep learning, accelerated computing, and advanced graphics (https://developer.nvidia.com/rdp/cudnn-download).

Now that we have installed NVIDIA's CUDA Toolkit and NVIDIA's cuDNN, our next step is to add environment paths.

You have been reading a chapter from
Hands-On Generative Adversarial Networks with Keras
Published in: May 2019
Publisher: Packt
ISBN-13: 9781789538205
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 £13.99/month. Cancel anytime
Visually different images