I have a question regarding selecting model parameters with optimal accuracy, here in below screenshot 2500th iteration have optimal accuracy and If I want to choose that particular model state in PyTorch, how should I do it? Please assist
- You could check in each iteration if the current accuracy is lesser than highest accuracy so far. If this happens for say n(3-5) iterations continuously, then you can stop.
Kindly refer to this for inspiration.
n_epochs_stop = 5 # no. of epochs to stop training after no improvement epochs_no_improve = 0 # keep track of no improvement epochs # inside the training loop ........ if epochs_no_improve == n_epochs_stop: print('Early stopping!' ) early_stop = True break else: continue break if early_stop: print("Stopped") break
- You could Pytorch-lightning, which has the
EarlyStoppingcallback - you can monitor any metric like val_loss, accuracy .