Skip to content
Discussion options

You must be logged in to vote

Hi @phongsakornpoom ,

Good question!

I don't have a specific function, but because PyTorch is so modular, you could create it yourself.

For example, if you wanted to perform early stopping, you could monitor the validation loss and stop training if it doesn't decrease after 5 epochs.

The following code is example of monitoring the validation loss and stopping training if it doesn't improve.

val_loss_lowest = 0

for epoch in range(epochs):
    # Do training

    # Validate
    val_loss = ...
    if epoch == 0:
        # Set the val_loss_lowest to be the val_loss for the first epoch
        val_loss_lowest = val_loss
    else:
        # If the new val_loss isn't lower than the lowest val_lo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by phongsakornpoom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants