Skip to content

Instantly share code, notes, and snippets.

@vishwanath79
Created June 20, 2020 23:13
Show Gist options
  • Select an option

  • Save vishwanath79/8308d2e1ae08b61d8687fd19a1fb994b to your computer and use it in GitHub Desktop.

Select an option

Save vishwanath79/8308d2e1ae08b61d8687fd19a1fb994b to your computer and use it in GitHub Desktop.

Revisions

  1. vishwanath79 created this gist Jun 20, 2020.
    18 changes: 18 additions & 0 deletions Combination
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    from keras.callbacks import EarlyStopping, ModelCheckpoint

    save_early_callback = EarlyStopping(monitor='val_loss', patience=5)
    save_best_callback = \
    ModelCheckpoint('/content/model-{epoch:02d}-{val_accuracy:.2f}.f5'
    , save_best_only=True, save_weights_only=True)
    model.fit(
    X_train,
    y_train,
    batch_size=64,
    class_weight=class_weight,
    validation_split=0.1,
    epochs=50,
    callbacks=[save_early_callback, save_best_callback],
    )