This project is a simple handwritten digit classifier using PyTorch and the MNIST dataset. The classifier is a neural network model that learns to recognize and classify handwritten digits (0-9) through supervised learning.
The purpose of this project is to demonstrate the process of building, training, and evaluating a neural network for digit classification. This project was created as part of my machine learning coursework to showcase my understanding of machine learning and neural networks.
The neural network model is defined in PyTorch, and it consists of four fully connected layers. The model is trained using the MNIST dataset, which contains 60,000 training images and 10,000 test images of handwritten digits.
- Input Layer: 28x28 pixels, flattened into 784 nodes.
- Hidden Layers: Three hidden layers, each with 64 nodes and ReLU activation.
- Output Layer: 10 nodes with log-softmax activation, representing the digit classes (0-9).
- Data Loading: The MNIST dataset is loaded and transformed into tensors.
- Model Initialization: The neural network model is created.
- Evaluation: Initial accuracy of the model is evaluated on the test set.
- Training: The model is trained for 2 epochs using the Adam optimizer and negative log-likelihood loss function.
- Evaluation: Accuracy of the model is evaluated after each epoch.
- Visualization: The first four test images are displayed with their predicted labels.
- Python 3.x
- PyTorch
- torchvision
- matplotlib