Building a simple neural network in PyTorch
We will now walk through building a neural network from scratch in PyTorch. Here, we have a small .csv
file containing several examples of images from the MNIST dataset. The MNIST dataset consists of a collection of hand-drawn digits between 0 and 9 that we want to attempt to classify. The following is an example from the MNIST dataset, consisting of a hand-drawn digit 1:
These images are 28x28 in size: 784 pixels in total. Our dataset in train.csv
consists of 1,000 of these images, with each consisting of 784 pixel values, as well as the correct classification of the digit (in this case, 1).
Loading the data
We will begin by loading the data, as follows:
- First, we need to load our training dataset, as follows:
train = pd.read_csv("train.csv") train_labels = train['label'].values train = train.drop("label",axis=1...