Early stopping in fastai library

(Irshad Muhammad) #1

How to use early stopping in fastai.
Found a relevant thread Wiki: Fastai Library Feature Requests but it doesn’t mention how can we use early stopping.

Adding @jeremy @rachel may be they know the answer?

1 Like

(Jeremy Howard (Admin)) #2

It’s not implemented yet - but you could do so easily enough with the callback mechanism in fastai.

2 Likes

(Odin) #3

Would be handy for the lesson 1 (and probably later, though at that point doing it yourself via callback is probably cool, but that’s how far I am). My “own” model got crazily overfitted quite soon with so few images.

0 Likes

(Vishal R) #4

Found this paper which describes a variety of useful early stopping methods.

0 Likes

(Cesar Calderon Muro) #5

@irshaduetian I was able to use early stopping with the following two lines (example for a text classifier):
from fastai.callbacks import *
learn = text_classifier_learner(data_clas, AWD_LSTM, drop_mult=0.1,callback_fns=[partial(EarlyStoppingCallback, monitor=‘accuracy’, min_delta=0.01, patience=2)])

0 Likes