A foundational deep learning project demonstrating a basic Convolutional Neural Network (CNN) implementation in PyTorch for classifying handwritten digits from the MNIST dataset.
This project is an excellent starting point for understanding core concepts of neural networks, data loading, model training, and evaluation in the PyTorch framework.
- Data Preparation: Loads the MNIST dataset and applies necessary normalization and tensor transformations.
- CNN Architecture: Implements a simple, two-layer CNN followed by max-pooling and fully connected layers.
- Training Loop: Includes a standard PyTorch training process using Adam optimization and Cross-Entropy Loss.
- Evaluation: Calculates the final test accuracy on unseen data.
- Visualization: Displays a sample test image with the model's prediction versus the actual label.
To run this code, you'll need the following Python libraries:
torch(PyTorch)torchvision(for datasets and transformations)matplotlibnumpy
You can install them using pip:
pip install torch torchvision matplotlib numpy