Skip to content

Instantly share code, notes, and snippets.

Created January 27, 2020 13:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
best_valid_loss = float('inf')
for epoch in range(N_EPOCHS):
#train the model
train_loss, train_acc = train(model, train_iterator, optimizer, criterion)
#evaluate the model
valid_loss, valid_acc = evaluate(model, valid_iterator, criterion)
#save the best model
if valid_loss < best_valid_loss:
best_valid_loss = valid_loss, '')
print(f'\tTrain Loss: {train_loss:.3f} | Train Acc: {train_acc*100:.2f}%')
print(f'\t Val. Loss: {valid_loss:.3f} | Val. Acc: {valid_acc*100:.2f}%')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment