This folder contains the package for prediction of the sum of a random single digit number and an MNIST image.
This project contains the following folder and file components:
- checkpoint - The folder where the model checkpoint is stored.
- config - The folder where the configuration file is stored.
- graphs - The package where the python module to plot output graphs exists.
- images - The folder where the output images (like graphs) are stored.
- models - The package where the python module for model/architecture exists.
- parsers - The package where the python modules to parse the configuration file and the command line arguments, exists.
- utils - The package where the python modules for utility functions like dataset, dataloader and for the processes like train, test and running the pipeline, exists.
- main.ipynb - The colab notebook file to run the entire process and displays log the outputs during the process. (Note: In this notebook, the process is run considering that the repository is already cloned to google drive.)
- main.py - The python file that contains the entry point to the entire pipeline.
Clone this repository.
Once the repository is cloned, type python main.py in the terminal. This will train the model.
Additionally, the python main.py will take four arguments -
- --mode -> Add --mode 'Train' to train the model or --mode 'Validate' to validate the model
- --config_path -> Add --config_path '<path to the configuration file>' to specify the path to the configuration file if it exists in a different folder. By default, the configuration file exists in the 'config' folder and this argument need not be provided if the same configuration file is used.
- --checkpoint_save -> Add --checkpoint_save '<path to save the checkpoint file>' to save the checkpoint of the model.
- --checkpoint_load -> Add --checkpoint_load '<path to load the checkpoint file from>' to load a saved checkpoint to the model.
For example, the following command will load the checkpoint file named 'mnist_sum.pth' from the path 'checkpoint/' to the model, train the model for a certain number of epochs specified in the configuration file and will then save the resulting model in the path 'checkpoint/' with the file name 'mnist_sum.pth' by replacing the previously existing checkpoint file, as it is of the same name:
python main.py --mode 'Train' --checkpoint_load './checkpoint/mnist_sum.pth' --checkpoint_save './checkpoint/mnist_sum.pth'
Upload this entire repository to your Google Drive manually or clone this repository onto your Google Drive through a google colab file by first mounting your google drive and changing the directory to the one where you need this repo to be cloned.
Once cloned, open the main.ipynb file and run all the commands or create your own colab file and change the working directory to cloned repo location on GDrive and type !python main.py. This will take 4 arguments too, as mentioned in the previous section related to the local desktop machine process.
For example,
!python main.py --mode 'Train' --checkpoint_load './checkpoint/mnist_sum.pth' --checkpoint_save './checkpoint/mnist_sum.pth'
The model/architecture used for this prediction has the following structure :
This model was trained for 25 epochs, using a batch size of 100 in the dataloaders, SGD as Optimiser and NLL Loss function (all of them specified in the configuration file) with no image preprocessing done on MNIST Images, in the Train mode. The highest sum prediction accuracy of 74.57 % was obtained on the validation set in the 25th epoch, wherein the MNIST Digit prediction accuracy was at 99.11 % for that epoch.
Validation on a random sample obtained from the validation set :
Graph for training mode accuracies on the Training Set vs Validation Set :
Graph for training mode losses on the Training Set vs Validation Set :



