I am training the Densenet121 Model on an image dataset. I divided the dataset into 80% for training and 20% for testing. Then I further divided the training data into 85% for training and 15% for validation. Now, after every epoch, I find the accuracy of the model. I save the model after the epoch in which it gives the highest accuracy on validation dataset. Then I evaluate this model on the completely unseen test dataset. Is this the right approach?

For example, I train the model for 10 epochs. After each epoch, the model gives following validation accuracies:

Epoch 1: 0.92
Epoch 2: 0.925
Epoch 3: 0.940
Epoch 4: 0.943
Epoch 5: 0.96
Epoch 6: 0.95
Epoch 7: 0.955
Epoch 8: 0.958
Epoch 8: 0.95
Epoch 9: 0.95
Epoch 10: 0.94

Since the accuracy is highest after 5th epoch, I select the model after the 5th epoch, and then test it on the unseen test dataset.
I am suspecting that because I am selectively choosing the model with highest validation accuracy, I might be introducing bias in my model.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.