Triggers


A trigger specifies a timespot or several timespots during training, and a corresponding action will be taken when the timespot(s) s reached.


Every Epoch

Scala:

 val trigger = Trigger.everyEpoch

Python:

 trigger = EveryEpoch()

A trigger that triggers an action when each epoch finishes. Could be used as trigger in setValidation and setCheckpoint in Optimizer, and also in TrainSummary.setSummaryTrigger.


Several Iteration

Scala:

 val trigger = Trigger.severalIteration(n)

Python:

 trigger = SeveralIteration(n)

A trigger that triggers an action every n iterations. Could be used as trigger in setValidation and setCheckpoint in Optimizer, and also in TrainSummary.setSummaryTrigger.


Max Epoch

Scala:

 val trigger = Trigger.maxEpoch(max)

Python:

 trigger = MaxEpoch(max)

A trigger that triggers an action when training reaches the number of epochs specified by "max". Usually used in Optimizer.setEndWhen.


Max Iteration

Scala:

 val trigger = Trigger.maxIteration(max)

Python:

 trigger = MaxIteration(max)

A trigger that triggers an action when training reaches the number of iterations specified by "max". Usually used in Optimizer.setEndWhen.


Max Score

Scala:

 val trigger = Trigger.maxScore(max)

Python:

 trigger = MaxScore(max)

A trigger that triggers an action when validation score larger than "max" score


Min Loss

Scala:

 val trigger = Trigger.minLoss(min)

Python:

 trigger = MinLoss(min)

A trigger that triggers an action when training loss less than "min" loss


And

Scala:

  val trigger = Trigger.and(Trigger.minLoss(0.01), Trigger.maxEpoch(2))

Python:

  trigger = TriggerAnd(MinLoss(0.01), MaxEpoch(2))

A trigger contains other triggers and triggers when all of them trigger (logical AND).

For example, TriggerAnd(MinLoss(0.01), MaxEpoch(2)), means training should stop when loss < 0.01 and epoch > 2.


Or

Scala:

  val trigger = Trigger.and(Trigger.minLoss(0.01), Trigger.maxEpoch(2))

Python:

  trigger = TriggerOr(MinLoss(0.01), MaxEpoch(2))

A trigger contains other triggers and triggers when all of them trigger (logical OR).

For example, TriggerOr(MinLoss(0.01), MaxEpoch(2)), means training should stop when loss < 0.01 or epoch > 2.