简体   繁体   中英

Early stopping using tensorflow tf.estimator ?

I am using tensorflow v1.4. I want to use early stopping using the validation set with a patience of 5 epochs.

I have searched on the web and found out that there used to be a function called ValidationMonitor but it is depreciated now. So is there a way to achieve this ?

Recently I have come across this function in tensorflow API. tf.keras.callbacks.EarlyStopping . tf version is r1.9.

Arguments:

  • monitor : quantity to be monitored
  • min_delta : minimum change in the monitored quantity to qualify as an improvement, ie an absolute change of less than min_delta, will count as no improvement.
  • patience : number of epochs with no improvement after which training will be stopped.
  • verbose : verbosity mode.
  • mode : one of { auto , min , max }. In min mode, training will stop when the quantity monitored has stopped decreasing; in max mode it will stop when the quantity monitored has stopped increasing; in auto mode, the direction is automatically inferred from the name of the monitored quantity.

There doesn't seem to be a good way of doing this, unfortunately. One method to consider is to save checkpoints quite often during training, and then later iterate over them and evaluating them. Then you can discard the checkpoints that does not have the best eval performance. This doesn't help you in saving time during training, but at least the resulting model you are left with is an early stopping model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM