Learn practical skills, build real-world projects, and advance your career

Training Deep Neural Networks on a GPU with PyTorch

alt

Preparing the Data

The data preparation is identical to the previous tutorial. We begin by importing the required modules & classes.

# Uncomment and run the commands below if imports fail
# !conda install numpy pandas pytorch torchvision cpuonly -c pytorch -y
# !pip install matplotlib --upgrade --quiet
import torch
import torchvision
import numpy as np
import matplotlib.pyplot as plt
import torch.nn as nn
import torch.nn.functional as F
from torchvision.datasets import MNIST
from torchvision.transforms import ToTensor
from torchvision.utils import make_grid
from torch.utils.data.dataloader import DataLoader
from torch.utils.data import random_split
%matplotlib inline

We download the data and create a PyTorch dataset using the MNIST class from torchvision.datasets.