How to implement early stopping as an extension

137 Views Asked by At

As this thread, we can stop iteration loop by setting function (f:trainer -> bool) as Trainer's stop_triger. But in this way, I think we can't use other extension such as LogReport which use stop_trigger=((args.epoch, '10')).

So, my question is how to implement early stopping as the Extension and how to send a signal to stop trainer's iteration from Extension.

thanks.

1

There are 1 best solutions below

1
On

I implemented the example code on gist, and updated the answer on the original thread.

I noticed that stop_trigger originally uses tuple notation like (args.epoch, '10'), instead we need to change to pass a callable object (EarlyStoppingTrigger in above example).