The Deep Learning with PyTorch Workshop

Book description

Get a head start in the world of AI and deep learning by developing your skills with PyTorch

Key Features

  • Learn how to define your own network architecture in deep learning
  • Implement helpful methods to create and train a model using PyTorch syntax
  • Discover how intelligent applications using features like image recognition and speech recognition really process your data

Book Description

Want to get to grips with one of the most popular machine learning libraries for deep learning? The Deep Learning with PyTorch Workshop will help you do just that, jumpstarting your knowledge of using PyTorch for deep learning even if you're starting from scratch.

It's no surprise that deep learning's popularity has risen steeply in the past few years, thanks to intelligent applications such as self-driving vehicles, chatbots, and voice-activated assistants that are making our lives easier. This book will take you inside the world of deep learning, where you'll use PyTorch to understand the complexity of neural network architectures.

The Deep Learning with PyTorch Workshop starts with an introduction to deep learning and its applications. You'll explore the syntax of PyTorch and learn how to define a network architecture and train a model. Next, you'll learn about three main neural network architectures - convolutional, artificial, and recurrent - and even solve real-world data problems using these networks. Later chapters will show you how to create a style transfer model to develop a new image from two images, before finally taking you through how RNNs store memory to solve key data issues.

By the end of this book, you'll have mastered the essential concepts, tools, and libraries of PyTorch to develop your own deep neural networks and intelligent apps.

What you will learn

  • Explore the different applications of deep learning
  • Understand the PyTorch approach to building neural networks
  • Create and train your very own perceptron using PyTorch
  • Solve regression problems using artificial neural networks (ANNs)
  • Handle computer vision problems with convolutional neural networks (CNNs)
  • Perform language translation tasks using recurrent neural networks (RNNs)

Who this book is for

This deep learning book is ideal for anyone who wants to create and train deep learning models using PyTorch. A solid understanding of the Python programming language and its packages will help you grasp the topics covered in the book more quickly.

Table of contents

  1. The Deep Learning with PyTorch Workshop
  2. Preface
    1. About the Book
      1. Audience
      2. About the Chapters
      3. Conventions
      4. Code Presentation
      5. Hardware Requirements
      6. Software Requirements
      7. Setting up Your Environment
      8. Installing Python on Windows and macOS
      9. Installing Python on Linux
      10. Installing pip
      11. Installing PyTorch
      12. Installing Libraries
      13. Opening a Jupyter Notebook
      14. Accessing the Code Files
  3. 1. Introduction to Deep Learning and PyTorch
    1. Introduction
    2. Why Deep Learning?
      1. Applications of Deep Learning
    3. Introduction to PyTorch
      1. GPUs in PyTorch
      2. What Are Tensors?
      3. Exercise 1.01: Creating Tensors of Different Ranks Using PyTorch
      4. Advantages of Using PyTorch
      5. Disadvantages of Using PyTorch
      6. Key Elements of PyTorch
        1. The PyTorch autograd Library
        2. The PyTorch nn Module
      7. Exercise 1.02: Defining a Single-Layer Architecture
        1. The PyTorch optim Package
      8. Exercise 1.03: Training a Neural Network
      9. Activity 1.01: Creating a Single-Layer Neural Network
    4. Summary
  4. 2. Building Blocks of Neural Networks
    1. Introduction
    2. Introduction to Neural Networks
      1. What Are Neural Networks?
      2. Exercise 2.01: Performing the Calculations of a Perceptron
      3. Multi-Layer Perceptron
      4. The Learning Process of a Neural Network
        1. Forward Propagation
        2. The Calculation of Loss Functions
        3. Backward Propagation
        4. Gradient Descent
      5. Advantages and Disadvantages
        1. Advantages
        2. Disadvantages
      6. Introduction to Artificial Neural Networks
      7. Introduction to Convolutional Neural Networks
      8. Introduction to Recurrent Neural Networks
    3. Data Preparation
      1. Dealing with Messy Data
      2. Exercise 2.02: Dealing with Messy Data
      3. Data Rescaling
      4. Exercise 2.03: Rescaling Data
      5. Splitting the Data
      6. Exercise 2.04: Splitting a Dataset
      7. Disadvantages of Failing to Prepare Your Data
      8. Activity 2.01: Performing Data Preparation
    4. Building a Deep Neural Network
      1. Exercise 2.05: Building a Deep Neural Network Using PyTorch
      2. Activity 2.02: Developing a Deep Learning Solution for a Regression Problem
    5. Summary
  5. 3. A Classification Problem Using DNN
    1. Introduction
    2. Problem Definition
      1. Deep Learning in Banking
      2. Exploring the Dataset
      3. Data Preparation
      4. Building the Model
      5. ANNs for Classification Tasks
      6. A Good Architecture
      7. PyTorch Custom Modules
      8. Exercise 3.01: Defining a Model's Architecture Using Custom Modules
      9. Defining the Loss Function and Training the Model
      10. Activity 3.01: Building an ANN
    3. Dealing with an Underfitted or Overfitted Model
      1. Error Analysis
      2. Exercise 3.02: Performing Error Analysis
      3. Activity 3.02: Improving a Model's Performance
    4. Deploying Your Model
      1. Saving and Loading Your Model
      2. PyTorch for Production in C++
      3. Building an API
      4. Exercise 3.03: Creating a Web API
      5. Activity 3.03: Making Use of Your Model
    5. Summary
  6. 4. Convolutional Neural Networks
    1. Introduction
    2. Building a CNN
      1. Why Are CNNs Used for Image Processing?
      2. The Image as Input
      3. Applications of CNNs
        1. Classification
        2. Localization
        3. Detection
        4. Segmentation
      4. The Building Blocks of CNNs
        1. Convolutional Layers
      5. Exercise 4.01: Calculating the Output Shape of a Convolutional Layer
        1. Pooling Layers
      6. Exercise 4.02: Calculating the Output Shape of a Set of Convolutional and Pooling Layers
        1. Fully Connected Layers
      7. Side Note – Downloading Datasets from PyTorch
      8. Activity 4.01: Building a CNN for an Image Classification Problem
    3. Data Augmentation
      1. Data Augmentation with PyTorch
      2. Activity 4.02: Implementing Data Augmentation
    4. Batch Normalization
      1. Batch Normalization with PyTorch
      2. Activity 4.03: Implementing Batch Normalization
    5. Summary
  7. 5. Style Transfer
    1. Introduction
    2. Style Transfer
      1. How Does It Work?
    3. Implementation of Style Transfer Using the VGG-19 Network Architecture
      1. Inputs – Loading and Displaying
      2. Exercise 5.01: Loading and Displaying Images
      3. Loading the Model
      4. Exercise 5.02: Loading a Pre-Trained Model in PyTorch
      5. Extracting the Features
      6. Exercise 5.03: Setting Up the Feature Extraction Process
      7. The Optimization Algorithm, Losses, and Parameter Update
        1. Content Loss
        2. Style Loss
        3. Total Loss
      8. Exercise 5.04: Creating the Target Image
      9. Activity 5.01: Performing Style Transfer
    4. Summary
  8. 6. Analyzing the Sequence of Data with RNNs
    1. Introduction
    2. Recurrent Neural Networks
      1. Applications of RNNs
      2. How Do RNNs Work?
      3. Input and Targets for Sequenced Data
      4. Exercise 6.01: Creating the Input and Target Variables for a Sequenced Data Problem
      5. RNNs in PyTorch
      6. Activity 6.01: Using a Simple RNN for a Time Series Prediction
    3. Long Short-Term Memory Networks
      1. Applications of LSTM Networks
      2. How Do LSTM Networks Work?
    4. LSTM Networks in PyTorch
      1. Preprocessing the Input Data
        1. Numbered Labels
        2. Generating the Batches
      2. One-Hot Encoding
      3. Exercise 6.02: Preprocessing the Input Data and Creating a One-Hot Matrix
      4. Building the Architecture
      5. Training the Model
      6. Performing Predictions
      7. Activity 6.02: Text Generation with LSTM Networks
    5. Natural Language Processing
      1. Sentiment Analysis
    6. Sentiment Analysis in PyTorch
      1. Preprocessing the Input Data
      2. Building the Architecture
      3. Training the Model
      4. Activity 6.03: Performing NLP for Sentiment Analysis
    7. Summary
  9. Appendix
    1. 1. Introduction to Deep Learning and PyTorch
      1. Activity 1.01: Creating a Single-Layer Neural Network
        1. Solution
    2. 2. Building Blocks of Neural Networks
      1. Activity 2.01: Performing Data Preparation
        1. Solution
      2. Activity 2.02: Developing a Deep Learning Solution for a Regression Problem
        1. Solution
    3. 3. A Classification Problem Using DNNs
      1. Activity 3.01: Building an ANN
      2. Activity 3.02: Improving a Model's Performance
      3. Activity 3.03: Making Use of Your Model
        1. Solution
    4. 4. Convolutional Neural Networks
      1. Activity 4.01: Building a CNN for an Image Classification Problem
        1. Solution
      2. Activity 4.02: Implementing Data Augmentation
        1. Solution
      3. Activity 4.03: Implementing Batch Normalization
        1. Solution
    5. 5. Style Transfer
      1. Activity 5.01: Performing Style Transfer
        1. Solution
    6. 6. Analyzing the Sequence of Data with RNNs
      1. Activity 6.01: Using a Simple RNN for a Time Series Prediction
        1. Solution
      2. Activity 6.02: Text Generation with LSTM Networks
        1. Solution
      3. Activity 6.03: Performing NLP for Sentiment Analysis
        1. Solution

Product information

  • Title: The Deep Learning with PyTorch Workshop
  • Author(s): Hyatt Saleh
  • Release date: July 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781838989217