pytorch_pfn_extras.training.triggers.BestValueTrigger#

class pytorch_pfn_extras.training.triggers.BestValueTrigger(key, compare, trigger=(1, 'epoch'))#

Bases: Trigger

Trigger invoked when specific value becomes best.

Parameters:
  • key (str) – Key of value.

  • compare (callable) – Compare function which takes current best value and new value and returns whether new value is better than current best.

  • trigger (TriggerLike) – Trigger that decides the comparison interval between current best value and new value. This must be a tuple in the form of <int>, 'epoch' or <int>, 'iteration' which is passed to IntervalTrigger.

Methods

__init__(key, compare[, trigger])

load_state_dict(to_load)

may_fire(iteration, epoch_length)

Flags if the trigger may fire at the current iteration

state_dict()

__call__(manager)#

Decides whether the extension should be called on this iteration.

Parameters:

manager (ExtensionsManager) – Manager object that this trigger is associated with. The observation of this manager is used to determine if the trigger should fire.

Returns:

True if the corresponding extension should be invoked in this iteration.

Return type:

bool

__init__(key, compare, trigger=(1, 'epoch'))#
Parameters:
  • key (str) –

  • compare (Callable[[float, float], bool]) –

  • trigger (TriggerLike) –

Return type:

None

load_state_dict(to_load)#
Parameters:

to_load (Dict[str, Any]) –

Return type:

None

may_fire(iteration, epoch_length)#

Flags if the trigger may fire at the current iteration

This must not alter the trigger state

Parameters:
  • iteration (int) –

  • epoch_length (int) –

Return type:

bool

state_dict()#
Return type:

Dict[str, Any]