Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saimadhu-polamuri/e8c25911f4d28c35034b0ecf85340d8f to your computer and use it in GitHub Desktop.
Save saimadhu-polamuri/e8c25911f4d28c35034b0ecf85340d8f to your computer and use it in GitHub Desktop.
## EarlyStopping with keras
from tensorflow.keras.callbacks import EarlyStopping
model = Sequential()
model.add(Dense(128, input_dim=2, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy',
optimizer='adam',
metrics=['accuracy'])
callback= EarlyStopping(monitor='val_loss')
history = model.fit(x_train, y_train,
validation_data=(x_test, y_test),
epochs=2000,callbacks=[callback])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment