Handwritten Digit Recognition in PyTorch

PyTorch (https://pytorch.org/) is an open-source machine learning framework developed at Facebook. It provides different components such as optimizers, loss functions, fully connected layers, activation function, etc. to build deep learning architectures. 

In this lab, we will learn how to recognize handwritten digits (0-9) in the MNIST Dataset using a simple network in PyTorch.

Importing Libraries

We import some libraries to help us build a neural network. While torch provides building blocks to create and train a network, torchvision provides some standard datasets, like the MNIST handwritten digits dataset, and how we can transform those datasets upon loading.

import torch # PyTorch 
from torchvision import datasets # Datasets module 
import torchvision.transforms as transforms # Image Transforms 
import matplotlib.pyplot as plt # Plotting Graphs and Images

 

Discussion