Book Image

Python Deep Learning - Second Edition

By : Ivan Vasilev, Daniel Slater, Gianmario Spacagna, Peter Roelants, Valentino Zocca
Book Image

Python Deep Learning - Second Edition

By: Ivan Vasilev, Daniel Slater, Gianmario Spacagna, Peter Roelants, Valentino Zocca

Overview of this book

With the surge in artificial intelligence in applications catering to both business and consumer needs, deep learning is more important than ever for meeting current and future market demands. With this book, you’ll explore deep learning, and learn how to put machine learning to use in your projects. This second edition of Python Deep Learning will get you up to speed with deep learning, deep neural networks, and how to train them with high-performance algorithms and popular Python frameworks. You’ll uncover different neural network architectures, such as convolutional networks, recurrent neural networks, long short-term memory (LSTM) networks, and capsule networks. You’ll also learn how to solve problems in the fields of computer vision, natural language processing (NLP), and speech recognition. You'll study generative model approaches such as variational autoencoders and Generative Adversarial Networks (GANs) to generate images. As you delve into newly evolved areas of reinforcement learning, you’ll gain an understanding of state-of-the-art algorithms that are the main components behind popular games Go, Atari, and Dota. By the end of the book, you will be well-versed with the theory of deep learning along with its real-world applications.
Table of Contents (12 chapters)

A CNN example with Keras and CIFAR-10

In Chapter 3, Deep Learning Fundamentals, we tried to classify the CIFAR-10 images with a fully-connected network, but we only managed 51% test accuracy. Let's see if we can do better with all the new things we've learned. This time we'll use CNN with data augmentation.

  1. We'll start with the imports. We'll use all the layers we introduced in this chapter, as shown in the following example:
import keras
from keras.datasets import cifar10
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Dense, Dropout, Activation, Flatten, BatchNormalization
from keras.models import Sequential
from keras.preprocessing.image import ImageDataGenerator
  1. We'll define the mini batch_size for convenience, as shown in the following code:
batch_size = 50
  1. Next, we'll import the CIFAR-10 dataset and we'll normalize...