Skip to content

Instantly share code, notes, and snippets.

@doleron
Last active April 16, 2023 14:53
Show Gist options
  • Save doleron/4105949067377043dc21f9b037d06ebb to your computer and use it in GitHub Desktop.
Save doleron/4105949067377043dc21f9b037d06ebb to your computer and use it in GitHub Desktop.
EPOCHS = 200
model.compile(loss=contrastive_loss_with_margin(margin=1), optimizer=tf.keras.optimizers.RMSprop(),
metrics=[Custom_Accuracy(), Custom_Precision(), Custom_Recall()])
early_stop = tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience = 30, start_from_epoch = 10)
checkpoint = tf.keras.callbacks.ModelCheckpoint(model_file, monitor="val_loss", mode="min", save_best_only=True, verbose=1)
history = model.fit(train_ds,
steps_per_epoch=(len(training_pairs) // TRAINING_BATCH_SIZE),
validation_data=validation_ds,
epochs=EPOCHS,
callbacks=[early_stop, checkpoint])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment