schedule
EpochScheduler
¶
Bases: Scheduler[T]
A scheduler which selects entries based on a specified epoch mapping.
This can be useful for making networks grow over time, or to use more challenging data augmentation as training progresses.
s = fe.schedule.EpochScheduler({1:"a", 3:"b", 4:None, 100: "c"})
s.get_current_value(epoch=1) # "a"
s.get_current_value(epoch=2) # "a"
s.get_current_value(epoch=3) # "b"
s.get_current_value(epoch=4) # None
s.get_current_value(epoch=99) # None
s.get_current_value(epoch=100) # "c"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
epoch_dict |
Dict[int, T]
|
A mapping from epoch -> element. For epochs in between keys in the dictionary, the closest prior key will be used to determine which element to return. None values may be used to cause nothing to happen for a particular epoch. |
required |
Raises:
Type | Description |
---|---|
AssertionError
|
If the |
Source code in fastestimator/fastestimator/schedule/schedule.py
RepeatScheduler
¶
Bases: Scheduler[T]
A scheduler which repeats a collection of entries one after another every epoch.
One case where this class would be useful is if you want to perform one version of an Op on even epochs, and a different version on odd epochs. None values can be used to achieve an end result of skipping an Op every so often.
s = fe.schedule.RepeatScheduler(["a", "b", "c"])
s.get_current_value(epoch=1) # "a"
s.get_current_value(epoch=2) # "b"
s.get_current_value(epoch=3) # "c"
s.get_current_value(epoch=4) # "a"
s.get_current_value(epoch=5) # "b"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repeat_list |
List[Optional[T]]
|
What elements to cycle between every epoch. Note that epochs start counting from 1. To have nothing |
required |
Raises:
Type | Description |
---|---|
AssertionError
|
If |
Source code in fastestimator/fastestimator/schedule/schedule.py
Scheduler
¶
Bases: Generic[T]
A class which can wrap things like Datasets and Ops to make their behavior epoch-dependent.
Source code in fastestimator/fastestimator/schedule/schedule.py
get_all_values
¶
Get a list of all the possible values stored in the Scheduler
.
Returns:
Type | Description |
---|---|
List[Optional[T]]
|
A list of all the values stored in the |
Source code in fastestimator/fastestimator/schedule/schedule.py
get_current_value
¶
Fetch whichever of the Scheduler
s elements is appropriate based on the current epoch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
epoch |
int
|
The current epoch. |
required |
Returns:
Type | Description |
---|---|
Optional[T]
|
The element from the Scheduler to be used at the given |
Source code in fastestimator/fastestimator/schedule/schedule.py
get_current_items
¶
Select items which should be executed for given mode, epoch, and ds_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items |
Iterable[Union[Any, Scheduler[Any]]]
|
A list of possible items or Schedulers of items to choose from. |
required |
run_modes |
Optional[Union[str, Iterable[str]]]
|
The desired execution mode. One or more of "train", "eval", "test", or "infer". If None, items of all modes will be returned. |
None
|
epoch |
Optional[int]
|
The desired execution epoch. If None, items across all epochs will be returned. |
None
|
ds_id |
Optional[Union[str, Iterable[str]]]
|
The desired one or more execution dataset id(s). If None, items across all ds_ids will be returned. An empty string indicates that positive matches should be excluded ('' != 'ds1'), but that negative matches are satisfied ('' == '!ds1'). |
None
|
Returns:
Type | Description |
---|---|
List[Any]
|
The items which should be executed. |
Source code in fastestimator/fastestimator/schedule/schedule.py
get_signature_epochs
¶
Find all epochs of changes due to schedulers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items |
List[Any]
|
List of items to scan from. |
required |
total_epochs |
int
|
The maximum epoch number to consider when searching for signature epochs. |
required |
mode |
Optional[str]
|
Current execution mode. If None, all execution modes will be considered. |
None
|
ds_id |
Optional[str]
|
Current ds_id. If None, all ds_ids will be considered. |
None
|
Returns:
Type | Description |
---|---|
List[int]
|
The epoch numbers of changes. |