Pages


<aside>

Home | Model Architechture | Model Training | Datasets | Data Preprocessing | Libraries | Training Analysis | Full Code Breakdown

</aside>


<aside>

Comparing between epoch with early stopping and epoch = 100

In this comparison, we will be taking a look at runs with early stopping module turned on as opposed to runs without early stopping meaning it will go to the maximum epoch which is 100.

Both runs used the same datasets and algorithm. Runs with early stopping module enabled usually results to around 30-50 epoch on average.

Let’s start with the learning rate fluctuation:

Starting with the epoch=100 run, we can see from the graph that it changes the learning rates steadily around epoch 25, 32, 55 and it changes erratically after that. This might indicates that the model is starting to overfitting and has reached it full potential around epoch 45 as frequent changes to learning rate every 10 epoch(10 is early_stopping module patience) means the model has stopped learning.

Learning rate change for epoch=100

Learning rate change for epoch=100

Looking at the graph for run with early stopping enabled, we can see that it stops at around 48 epoch. This match with our previous observation that at around epoch 45 is where the model has reached max potential and it will only start overfitting the model if it continues. From here we can conclude that, the early stopping module is really helpful as it can help us save time by running only the required epoch to train the model.

Learning rate change for epoch with early stopping

Learning rate change for epoch with early stopping

Next, we will take a look at the loss graphs:

We have two loss graphs which is training loss and validation loss. Training loss measures how well the model performs on the training dataset, focusing on minimizing error during training. Meanwhile, Validation loss evaluates the model's performance on a separate validation dataset to check generalization to unseen data.

This is the graph for training and validation loss for run with epoch=100, we can see a few patterns here, starting with the training loss graph. If we look closely, the graph seems to be going down steadily until around epoch 40 where it starts to get more plateaued. Moving over to the validation graph, we can clearly see that after epoch 45, the graph starts to get more spiky. This means at around that point the model is already overfitting as in most cases overfitting will cause the model to lose more accurracy.

Training and Validation loss for epoch=100

Training and Validation loss for epoch=100

Comparing it to run with early stopping enabled, we can see that the training stops right at the point where the model starts to overfitting in the previous example. The training graph lowers smoothly without that many of a bump and the validation loss graph stops at around 0.27 which is the acceptable spot for our model to have a balance of accuracy and training.

image.png

Conclusion:

Comparing the two training runs, the run with early stopping demonstrates a clear advantage. The 100-epoch run, while achieving a lower training loss, exhibits clear signs of overfitting after approximately epoch 40, with the validation loss becoming erratic and failing to improve significantly. In contrast, the early stopping mechanism halted training at around epoch 45, at which point the validation loss was at its minimum and significantly lower than the validation loss achieved at any point after epoch 50 in the 100-epoch run.

This demonstrates the effectiveness of early stopping in preventing overfitting, resulting in better generalization performance on the validation set, and also saving 55 epochs of training time. Therefore, early stopping is a crucial technique for efficient and effective model training.

</aside>