Neural Networks (MLP)

Neural Networks (MLP)#

Neural networks are a class of machine learning models designed around the idea of processing data through layers of interconnected neurons. In the simplest setting, data flows in one direction, from the input layer to the output layer. The input layer receives data, the intermediate layers transform it into increasingly meaningful representations, and the output layer produces the final result.

In this chapter, we will take a look at a first concrete example of a neural network in PyTorch. The problem we are trying to solve here is to classify grayscale images of handwritten digits (28 pixels by 28 pixels), into their 10 categories (0 to 9). The dataset we will use is the MNIST dataset, which contains a set of 60,000 training images, plus 10,000 test images. You can think of “solving” MNIST as the “Hello World” of deep learning: it’s what you do to verify that your algorithms are working as expected. As you become a machine learning practitioner, you will see MNIST come up over and over again, in scientific papers, blog posts, and so on.

Our workflow will be as follow.

  • Load the dataset.

  • Build the neural network.

  • Train the network on pairs of images and labels from the training set.

  • Evaluate the network on test images, and verify if these predictions match the labels.

By the end of this chapter, we will have a neural network that can classify handwritten digits.

MNIST