π€ MNIST Digit Classifier β PyTorch
A Convolutional Neural Network (CNN) built using PyTorch to classify handwritten digits from the MNIST dataset.
This project loads a trained model and predicts digits from custom images.
π Features
- Dataset: MNIST (28Γ28 grayscale digit images)
- Model Architecture:
- 3 Convolutional Layers + ReLU activation
- Flatten layer
- Fully Connected Layer (10 outputs for digits 0β9)
- Loss Function: CrossEntropyLoss
- Optimizer: Adam
- Device Support: GPU (CUDA) or CPU
π Project Structure βββ data/ # MNIST dataset (auto-downloaded) βββ img_1.jpg # Sample image for prediction βββ model_state.pt # Saved model weights βββ torchnn.py # Main script βββ README.md # Documentation
π Installation
1οΈβ£ Clone the repository : --bash : git clone https://github.com/RIVALHIDE/pytorch-minst.git cd RIVALHIDE
2οΈβ£ Create a virtual environment : --bash: python -m venv .venv
3οΈβ£ Activate the environment :
Windows: --bash : .venv\Scripts\activate
4οΈβ£ Install dependencies : --bash : pip install torch torchvision pillow
Run the prediction script: --bash : python torchnn.py
Example Output: Using device: cpu Total parameters: 365514 Predicted Digit: 7