We compare four popular optimization algorithms - Stochastic Gradient Descent (SGD), Adaptive Gradient Method (Adagrad), Root Mean Squared Propagation (RMSProp), and Adaptive Moment Estimation (ADAM) - across three large publicly available datasets: CIFAR-10 for image classification, and SST-2 and MNLI for natural language processing tasks.
We observe that RMSProp exhibits unstable convergence and consistently underperforms compared to the other methods. Adagrad and Adam perform similarly on CIFAR-10 and SST-2, but Adam notably outperforms Adagrad on the more challenging MNLI dataset.
To reproduce our experiments, please install the dependencies in requirements.txt and run the command:
main.py --model [distilbert|resnet] --dataset [cifar10|sst2|mnli] --lr <sety value as described below>
The command will run all optimizers on a given task/model combination. Note, that resnet only supports cifar10 data, while distilbert only supports sst2|mnli data.
The task of fitting a deep learning model to data
At each training iteration
In selecting optimization algorithms to benchmark, we draw inspiration from Sebastian Ruder's Blog. We compare the following methods:
SGD proposes a simple update rule, which uses only one hyperparameter
Adagrad keeps track of the sum of gradient squared and uses that to adapt the gradient in different directions. The idea is that the learning rate then adapts for each weight in the model. It also decays the learning rate
Looking at the update history we see that if the accumulated gradient is small then
RMSProp handles the learning rate by maintaining a moving average of the squares of gradients for each weight and dividing the learning rate by that. This is similar to Adagrad. The only difference is that it adds a decay factor to the gradient squares. This is supposed to make RMSProp much quicker than Adagrad since Adagrad decays the learning rate very aggressively.
Here,
Adam combines RMSProp and momentum. It uses both the sum of gradients and the sum of squared gradients. It also applies a bias-correction on the first and second moments:
We run our experiments on Nvidia A100 GPU in the Google Collab environment. We use a batch size of 512 and a constant learning rate, which we tune for each task. We use the accuracy metric to evaluate our models.
The CIFAR-10 datset contains
We finetune a ResNet-50 checkpoint with learning rate
We achieve the best classification accuracy of
Based on the loss and accuracy curves, we observe that the Adam optimizer achieves the highest accuracy while having the fastest convergence in both training and test loss.
Figure 1: CIFAR-10 training loss curves. RMSProp is the most unstable, while Adagrad is the most stable optimizer. Adam has the fastest convergence.
Figures 2 and 3: CIFAR-10 evaluation loss and accuracy curves. Adagrad is most stable, while Adam is most performant.
The Stanford Sentiment Treebank dataset consists of 67,349 training and 872 test phrases extracted from movie reviews, along with human-judged binary sentiment annotations (positive/negative). The task is to predict the sentiment of each phrase.
We finetune DistilBERT on the task with a learning rate of
Based on evaluation results in Figures 5 and 6, we see that SGD has the least training loss while Adam and Adagrad have the best accuracy. We also note that Adam reaches peak accuracy of
We also highlight that we have selected learning rates to be
Figure 4: SST2 training loss curves. RMSProp and SGD are the most unstable. Adam has the fastest convergence.
Figures 5 and 6: SST2 evaluation loss and accuracy curves. SGD has the lowest evaluation loss, but Adam and Adagrad have the highest accuracy. The increasing evaluation loss indicates potential overfitting.
The Multi-Genre Natural Language Inference Corpus is a dataset of sentence pairs with a crowd-sourced textual annotation labels. The first sentence in the pair is the premise and the second one is the hypothesis. The task is to decide whether the premise entails the hypothesis: contradiction (0), neutral (1), and entailment (2). The test set is split into the "matched" category which resembles the distribution of the training data and the "mismatched" category which does not. We evaluate only on the "matched" test category. The training set has 392,702 examples, and the "matched" test set has 9,815 examples.
Before comparing the optimizers, we want to address why RMSProp is not included in any of the figures below. RMSProp proved to be too unstable and was not able to decrease the training loss. We tried multiple learning rates to no avail.
We finetune DistilBERT on the task with learning rate of
Looking at the plots in Figures 8 and 9, we note that Adam has the least loss and the highest test accuracy of
Figure 7: MNLI training loss. All the optimizers are oscillating while decreasing. Adam is doing slightly better than the others.
Figures 8 and 9: MNLI evaluation loss and accuracy curves. Adam has the lowest evaluation loss and the highest training accuracy.
In the course of the comparison, we observe that SGD and RMSProp performs worse than the other two optimization methods. Specifically, SGD makes the least magnitude updates per step, while RMSProp updates too much, which leads to instability. SGD trains consistently across all the examples, but does not achieve the accuracy of AdaGrad or Adam. Adagrad and ADAM perform similarly on CIFAR-10 and SST2, however Adam is notably better on MNLI which is by far the most challenging dataset.

