Book Image

The Deep Learning with PyTorch Workshop

By : Hyatt Saleh
Book Image

The Deep Learning with PyTorch Workshop

By: Hyatt Saleh

Overview of this book

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.
Table of Contents (8 chapters)

2. Building Blocks of Neural Networks

Activity 2.01: Performing Data Preparation

Solution

  1. Import the required libraries:
    import pandas as pd
  2. Using pandas, load the .csv file:
    data = pd.read_csv("YearPredictionMSD.csv", nrows=50000)
    data.head()

    Note

    To avoid memory limitations, use the nrows argument when reading the text file in order to read a smaller section of the entire dataset. In the preceding example, we are reading the first 50,000 rows.

    The output is as follows:

    Figure 2.33: YearPredictionMSD.csv

  3. Verify whether any qualitative data is present in the dataset:
    cols = data.columns
    num_cols = data._get_numeric_data().columns
    list(set(cols) - set(num_cols))

    The output should be an empty list, meaning there are no qualitative features.

  4. Check for missing values.

    If you add an additional sum() function to the line of code that was previously used for this purpose, you will get the sum of missing values in the entire dataset, without discriminating by column...