pytorch_pfn_extras.training.trigger.get_trigger#
- pytorch_pfn_extras.training.trigger.get_trigger(trigger)#
Gets a trigger object.
Trigger object is a callable that accepts a
ExtensionsManagerobject as an argument and returns a boolean value. When it returns True, various kinds of events can occur depending on the context in which the trigger is used. For example, if the trigger is passed to theextend()method of a manager, then the registered extension is invoked only when the trigger returns True.This function returns a trigger object based on the argument. If
triggeris already a callable, it just returns the trigger. IftriggerisNone, it returns a trigger that never fires. Otherwise, it creates aIntervalTrigger.- Parameters:
trigger (Optional[Union[Trigger, Callable[[ExtensionsManagerProtocol], bool], Tuple[float, str]]]) – Trigger object. It can be either an already built trigger object (i.e., a callable object that accepts a manager object and returns a bool value), or a tuple. In latter case, the tuple is passed to
IntervalTrigger.- Returns:
triggerif it is a callable, otherwise aIntervalTriggerobject made fromtrigger.- Return type: