I describe an algorithm to determine the number of iterations hyperparameter of neural networks.
In the deep learning literature, the early stopping algorithm determines the optimal number of iterations that a neural network runs in order to update its weights. One drawback to the algorithm is that it only minimizes validation set error (which differs from training set error). Hence, early stopping may result in underfitting data (i.e. evidenced by high training set error). Instead of focusing solely on minimizing validation set error, what if the training set error was also incorporated into determining the optimal number of iterations for a neural network? Would this be a good idea?
In theoretical economics, many models start with some general properties to reach some conclusion. From this perspective, I propose some general properties that I would like an algorithm to satisfy in order to determine the optimal number of iterations hyperparameter. I call this new algorithm A-Early Stopping or (AES) from now on.
I now propose two properties that AES focuses on. The first relates to minimizing the distance between the validation and training set error and the second is minimizing the total error. For the former property, since we often want to balance these errors in order to not underfit or overfit, we want these numbers to be as close as possible to each other. There are a few ways to measure the distance between these numbers.
The first way is to find the absolute distance. Given positive real numbers and , the absolute distance is simply . The second way to measure the distance between validation and training set error is to find the relative distance. Given positive real numbers and , the relative distance is . The primary difference between these two methods is that when both and are the same distance away from one another but both are large numbers, their relative distance will be smaller than if both numbers were smaller. For example, in the table below, minimizing the relative distance would favor a training set error of 2 and a validation set error of 3 over 1 and 2.
The second property of AES is simply to minimize the total error. Hence, the objective function that the algorithm should minimize consists of two parts.
Suppose there are number of total iterations that the neural network runs in order to update its parameters. For all , let and be the validation error and training error on iteration . The absolute error on any iteration is . Likewise, the relative error is . Let the function be either the absolute or relative error .
The objective function to find the optimal number of iterations is then as follows.
The algorithm that solves the problem above should then store the parameters associated with that optimal number of iterations.
In order to further analyze the relative error function, I make an important definition. The relative error function prefers lowering the training set error over the validation set error compared to the other error function if the training set error is lower than the validation set error if and only if is less than . Likewise, error function prefers lowering the validation set error over the training set error compared to the other error function if the validation set error is lower than the training set error if and only if is less than .
Now consider another problem involving two different cases of training and validation set errors. Let be the training and validation set errors for one case and be the errors for the second case. Further, since training error is typically lower than validation error because of overfitting, suppose that and . I want to make sure that in cases where the training set error is the same but the validation set error is less in one case compared to the other, the objective function prefers the case with the lower validation set error. For example, suppose and , the objective function should produce a lower number for than . To capture this idea, I create another definition. The objective function is rational if whenever and and whenever and .
I dig a little deeper into the implications of this simple algorithm.
The relative error function prefers lowering the training set error over the validation set error compared to the relative error function . Further, the relative error function prefers lowering the validation set error over the training set error compared to .
Suppose . Hence, let where . Then we have
and
Hence, since , we have that . Likewise, . WLOG, if , then .
The above statement is relevant because the choice of the relative error function matters. For example, if one wanted to focus on reducing validation error, then should be chosen over . Hence, it should be noted that the objective function would prefer validation error over training error.
For the absolute error function , it can be said that it is indifferent between training and validation errors because . Hence, when the validation and training errors are switched, the absolute error remains the same.
The objective function is rational when .
Case 1. Suppose that . Then we know that and . Hence,
Further, since and , we have and . Hence, and . Therefore, we have,
Case 2. Suppose and and . Then we have , which implies
The above proposition essentially advocates for using the objective function because of its rationality property. Although there may be other objective functions to determine the number of iterations hyperparameters containing other desirable properties (that I may not have defined in this post), I stop my analysis here. Further investigations of this topic may include finding rational objective functions for validation errors that are less than one.