Abstract
Machine learning models are often learned by minimising a loss function on the training data using a gradient descent algorithm. These models often suffer from overfitting, leading to a decline in predictive performance on unseen data. A standard solution is early stopping using a hold-out validation set, which halts the minimisation when the validation loss stops decreasing. However, this hold-out set reduces the data available for training. This paper presents GRADSTOP, a novel stochastic early stopping method that only uses information in the gradients, which are produced by the gradient descent algorithm "for free." Our main contributions are that we estimate the Bayesian posterior by the gradient information, define the early stopping problem as drawing sample from this posterior, and use the approximated posterior to obtain a stopping criterion. Our empirical evaluation shows that GRADSTOP achieves a small loss on test data and compares favourably to a validation-set-based stopping criterion. By leveraging the entire dataset for training, our method is particularly advantageous in data-limited settings, such as transfer learning. It can be incorporated as an optional feature in gradient descent libraries with only a small computational overhead. The source code is available at https://github.com/edahelsinki/gradstop.
Introduction
In deep learning, early stopping is the primary defense against overfitting. The standard approach involves splitting the available data into training and validation sets, halting the optimization when performance on the hold-out validation set begins to degrade. However, this practice imposes a "data tax," which is particularly costly in data-scarce fields such as medical imaging or transfer learning. Giving up 20% of a small dataset for validation can significantly weaken the final model's predictive power.
GRADSTOP addresses this by providing a theoretically justified, "free" stopping criterion that uses only the gradient information already generated during standard training. By eliminating the need for a validation set, researchers can utilize 100% of their data for model fitting.
Methodology: Bayesian Posterior Sampling
The core innovation of GRADSTOP is viewing the sequence of parameters produced by gradient descent as a path through a Bayesian posterior distribution. The method assumes the loss function is essentially a negative log-posterior and aims to stop when the model reaches a state that represents a valid sample from this distribution.
The Credibility Value
GRADSTOP defines a "credibility value" $s(\theta)$, representing the probability mass of the posterior within a specific level set (a contour line of the distribution). During training, the algorithm calculates an estimated credibility value $s_t$ at each step $t$. The stopping point is determined by drawing a random number $u$ from a uniform distribution and stopping when $s_t$ is closest to $u$.
Gradient Approximation
To avoid expensive MCMC sampling, GRADSTOP approximates the posterior's shape using the mean gradient and the gradient covariance matrix. Leveraging the "Information Equality" in statistics, the authors demonstrate that the Hessian (the curvature of the loss) can be estimated using these first-order gradients, making the computation highly efficient.
Empirical Evaluation
The authors evaluated GRADSTOP across various regimes, including medical tabular data (UCI Heart Disease, Diabetes, Hepatitis) and image classification transfer learning (MNIST, FashionMNIST, CIFAR-10).
Key Results
- Data-Limited Performance: On the Heart Disease dataset, GRADSTOP achieved a test loss of 1.055, significantly outperforming the standard validation-set approach (1.138) and other no-validation baselines like GSNR.
- Transfer Learning: In transfer learning tasks, GRADSTOP consistently outperformed validation-set stopping, particularly when the transfer set size was small. By utilizing the entire dataset for training, the model achieved higher peak accuracy and lower loss.
- Robustness to Noise: When tested with noisy labels (10% to 35% mislabeling), GRADSTOP effectively prevented the model from memorizing noise, maintaining higher accuracy than fixed-epoch training.
Discussion and Future Work
GRADSTOP provides a robust alternative to validation-based early stopping with minimal computational overhead. Currently, the theory relies on full-batch gradients and assumes a locally quadratic loss surface. Future research will focus on extending the method to mini-batch stochastic gradient descent (SGD) and exploring its application in multi-objective optimization tasks like Generative Adversarial Networks (GANs).
Summary updated