text: 
  
  TITLE
  saving best model only using modelcheckpoint keras
  
  COMMENTS
  3
  
  REACTIONS
  +1: 0
  -1: 0
  laugh: 0
  hooray: 0
  heart: 0
  rocket: 0
  eyes: 0
  
  BODY
  while using model.fit for training a Transformer model, how to use `tf.keras.callbacks.ModelCheckpoint` with `'save_best_only=True'` to save only the best model?
  
  `model.fit([input_ids_train, attention_mask_train], train_labels,
            validation_data=([input_ids_valid, attention_mask_valid], valid_labels),
            epochs=50, batch_size=32)`
  