Skip to content

Implementation and comparison of SGD, SGD with momentum, RMSProp and AMSGrad optimizers on the Image classification task using MNIST dataset

Notifications You must be signed in to change notification settings

EliaFantini/RMSProp-and-AMSGrad-for-MNIST-image-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🆚RMSProp_vs_ADAGrad GitHub commit activity GitHub last commit GitHub code size GitHub repo size GitHub follow GitHub fork GitHub watchers GitHub star

Implementation of different first order (FO) stochastic methods: stochastic gradient descent (SGD), stochastic gradient descent with momentum (SGDw/Momentum) , Root Mean Squared Propagation (RMSProp), Adaptive Gradient Algorithm (Adagrad). This project was made to test these different optimizers on a handwritten digit classifier using the well-known MNIST dataset. This dataset has 60000 training images, and 10000 test images. Each image is of size 28 × 28 pixels, and shows a digit from 0 to 9.

For a more detailed explanation of the algorithms mentioned above, please read Exercise instructions.pdf, it contains also some theoretical questions answered in Answers.pdf (handwritten).

The project was part of an assignment for the EPFL course EE-556 Mathematics of data: from theory to computation. The backbone of the code structure to run the experiments was already given by the professor and his assistants, what I had to do was to implement the core theoretical concepts to actually make the experiments work. Hence, every code file is a combination of my personal code and the code that was given us by the professor.

The following table shows a summary of the training done by running main.py in the code folder.

Immagine 2022-08-07 114348

The following image shows an example of the output figures of the code main.py. All plots show a comparison of convergence speed to the optimal loss and accuracy, for different learning rate's values.

Immagine 2022-08-07 114322 Immagine 2022-08-07 114311 Immagine 2022-08-07 114333

Author

How to install and reproduce results

Download this repository as a zip file and extract it into a folder The easiest way to run the code is to install Anaconda 3 distribution (available for Windows, macOS and Linux). To do so, follow the guidelines from the official website (select python of version 3): https://www.anaconda.com/download/

Additional package required are:

  • matplotlib
  • pytorch

To install them write the following command on Anaconda Prompt (anaconda3):

cd *THE_FOLDER_PATH_WHERE_YOU_DOWNLOADED_AND_EXTRACTED_THIS_REPOSITORY*

Then write for each of the mentioned packages:

conda install *PACKAGE_NAME*

Some packages might require more complex installation procedures (especially pytorch). If the above command doesn't work for a package, just google "How to install PACKAGE_NAME on YOUR_MACHINE'S_OS" and follow those guides.

Finally, run main.py.

python main.py

Files description

  • code/: folder containing all the code to run the training and testing, included the optimization algorithms

  • code/main.py: main script to be run in order to do the training and output the plots.

  • Answers.pdf: pdf with the answers and plots to the assignment of the course

  • Exercise instructions.pdf: pdf with the questions of the assignment of the course

🛠 Skills

Python, Pytorch, Matplotlib. Machine learning, artificial neural networks, multilayer perceptron (MLP), implementation of optimization methods.

🔗 Links

portfolio linkedin

About

Implementation and comparison of SGD, SGD with momentum, RMSProp and AMSGrad optimizers on the Image classification task using MNIST dataset

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages