Machine learning is fast becoming the preferred way to solve data problems, thanks to
the huge variety of mathematical algorithms that find patterns otherwise invisible to us.
Applied Deep Learning with PyTorch takes your understanding of deep learning, its
algorithms, and its applications to a higher level. The book begins by helping you
browse through the basics of deep learning and PyTorch. Once you are well versed
with the PyTorch syntax and capable of building a single-layer neural network,
you will gradually learn to tackle more complex data problems by configuring and
training a convolutional neural network (CNN) to perform image classification. As you
progress through the chapters, you'll discover how you can solve an NLP problem by
implementing a recurrent neural network (RNN).
By the end of this book, you'll be able to apply the skills and confidence you've gathered
along your learning process to use PyTorch for building deep learning solutions that
can solve your business data problems.
Table of Contents
Preface i
Introduction to Deep Learning and PyTorch 1
Introduction
Understanding Deep Learning
Why Is Deep Learning Important? Why Has It Become Popular?
Applications of Deep Learning
PyTorch Introduction
Advantages
Disadvantages
What Are Tensors?
Exercise 1: Creating Tensors of Different Ranks Using PyTorch
Key Elements of PyTorch
Activity 1: Creating a Single-Layer Neural Network
Summary
Building Blocks of Neural Networks 21
Introduction
Introduction to Neural Networks
What Are Neural Networks?
Exercise 2: Performing the Calculations of a Perceptron
Multi-Layer Perceptron
The Learning Process of a Neural Network
Advantages and Disadvantages
Introduction to Artificial Neural Networks
Introduction to Convolutional Neural Networks
Introduction to Recurrent Neural Networks
Data Preparation
Dealing with Messy Data
Exercise 3: Dealing with Messy Data
Data Rescaling
Exercise 4: Rescaling Data
Splitting the Data
Exercise 5: Splitting a Dataset
Activity 2: Performing Data Preparation
Building a Deep Neural Network
Exercise 6: Building a Deep Neural Network Using PyTorch
Activity 3: Developing a Deep Learning Solution
for a Regression Problem
Summary
A Classification Problem Using DNNs 59
Introduction
Problem Definition
Deep Learning in Banking
Exploring the Dataset
Data Preparation
Building the Model
ANNs for Classification Tasks
A Good Architecture
PyTorch Custom Modules
Activity 4: Building an ANN
Dealing with an Underfitted or Overfitted Model
Error Analysis
Exercise 7: Performing Error Analysis
Activity 5: Improving a Model's Performance
Deploying Your Model
Saving and Loading Your Model
PyTorch for Production in C++
Activity 6: Making Use of Your Model
Summary
Convolutional Neural Networks 95
Introduction
Building a CNN
Why CNNs?
The Inputs
Applications of CNNs
Building Blocks of CNNs
Exercise 8: Calculating the Output Shape of a Convolutional Layer
Exercise 9: Calculating the Output Shape of a set of Convolutional
and Pooling Layers
Side Note – Downloading Datasets from PyTorch
Activity 7: Building a CNN for an Image Classification Problem
Data Augmentation
Data Augmentation with PyTorch
Activity 8: Implementing Data Augmentation
Batch Normalization
Batch Normalization with PyTorch
Activity 9: Implementing Batch Normalization
Summary
Style Transfer 127
Introduction
Style Transfer
How Does It Work?
Implementation of Style Transfer Using the VGG-19
Network Architecture
Inputs: Loading and Displaying
Exercise 10: Loading and Displaying Images
Loading the Model
Exercise 11: Loading a Pretrained Model in PyTorch
Extracting the Features .
Exercise 12: Setting up the Feature Extraction Process
The Optimization Algorithm, Losses, and Parameter Updates .
Exercise 13: Creating the Target Image .
Activity 10: Performing Style Transfer .
Summary
Analyzing the Sequence of Data with RNNs 151
Introduction .
Recurrent Neural Networks
Applications of RNNs
How Do RNNs Work? .
RNNs in PyTorch
Activity 11: Using a Simple RNN for a Time Series Prediction .
Long Short-Term Memory Networks (LSTMs)
Applications .
How Do LSTM Networks Work?
LSTM Networks in PyTorch
Preprocessing the Input Data .
One-Hot Encoding
Building the Architecture .
Training the Model
Performing Predictions
Activity 12: Text Generation with LSTM Networks
Natural Language Processing (NLP) .
Sentiment Analysis .
Sentiment Analysis in PyTorch
Preprocessing the Input Data .
Building the Architecture .
Training the Model ..
Activity 13: Performing NLP for Sentiment Analysis
Summary .