This device is not compatible.


Build a Classifier for Handwritten Digits

In this project, you’ll use a deep neural network to recognize handwritten digits. You'll use the images of handwritten digits from the MNIST dataset.

Build a Classifier for Handwritten Digits

You will learn to:

Load the MNIST dataset using PyTorch.

Build a deep neural network using PyTorch.

Train a deep neural network using PyTorch.

Convert image data to tensors.


Machine Learning

Neural Networks

Deep Neural Networks


Intermediate knowledge of Python

Basic knowledge of Matplotlib

Basic knowledge of neural networks




Project Description

It might be easy for us to recognize the blurred image given below because of the brain’s amazing functionality, but it’s not as simple for computers.

Sample image from MNIST
Sample image from MNIST

We can recognize it with such ease, possibly because we’ve seen so many different variants of the digit “6” that our brain has learned to recognize it in various forms. There is an area of machine learning called deep learning that mimics this learning mechanism of the human brain—learning by example.

Deep learning is based on neural networks that are made up of different layers of linked “neurons.” It is inspired by the structure and function of the neurons in the human brain. We need massive amounts of data and complex algorithms to train a neural network.

In this project, we will use PyTorch to implement a deep learning algorithm to recognize handwritten digits. We will use the MNIST dataset to complete this project. It is a collection of 70,000 handwritten digits divided into a training set of 60,000 images and a test set of 10,000 images.

Project Tasks

Task 1: Import Modules

Task 2: Download and Load the Datasets

Task 3: Build and Train the Model