Skip to content

Commit

Permalink
Implemented early stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
Subodh Malgonde authored and Subodh Malgonde committed Dec 21, 2017
1 parent 7c5f2e6 commit b8610d8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ def train_nn(sess, epochs, data_folder, image_shape, batch_size, training_image_
training_loss_metrics.append(training_loss)
training_accuracy_metrics.append(training_accuracy)

if epoch > 0 and (training_accuracy_metrics[-1] < training_accuracy_metrics[-2] - 0.01):
print("Early stopping!!!!")
break

print(
"Epoch %d:" % (epoch + 1),
"Training loss: %.4f, accuracy: %.2f" % (training_loss, training_accuracy),
Expand Down

0 comments on commit b8610d8

Please sign in to comment.