This repo trains a DenseNet-121 model on the MNIST dataset. The dataset is resized and normalized to fit the DenseNet model, and training is done using PyTorch.
To set up the environment, use the following commands:
conda create --name pytorch_env python=3.11.9 --file requirements.txt
conda activate pytorch_env- Dataset is loaded using
torchvision.datasets.MNIST. - Images are resized to 224x224, normalized, and converted to tensors.
The combined training and test dataset is split into:
- Training Set: 42,000 samples
- Validation Set: 14,000 samples
- Test Set: 14,000 samples
- DenseNet-121 is loaded and modified for single-channel input and 10 output classes.
- Model is moved to GPU if available.
- Loss Function: CrossEntropyLoss
- Optimizer: Adam with learning rate 0.001


