trace
EvalEssential
¶
Bases: Trace
A trace to collect important information during evaluation.
Please don't add this trace into an estimator manually. FastEstimator will add it automatically.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
monitor_names |
Set[str]
|
Any keys which should be collected over the course of an eval epoch. |
required |
Source code in fastestimator/fastestimator/trace/trace.py
Logger
¶
Bases: Trace
A Trace that prints log messages.
Please don't add this trace into an estimator manually. FastEstimator will add it automatically.
Source code in fastestimator/fastestimator/trace/trace.py
PerDSTrace
¶
Bases: Trace
Source code in fastestimator/fastestimator/trace/trace.py
on_ds_begin
¶
Runs at the beginning of each dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
A dictionary through which traces can communicate with each other. Output here will not be logged. |
required |
on_ds_end
¶
Runs at the beginning of each dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
A dictionary through which traces can communicate with each other. Output here will be accumulated across all available datasets and then logged during on_epoch_end. |
required |
Source code in fastestimator/fastestimator/trace/trace.py
TestEssential
¶
Bases: Trace
A trace to collect important information during evaluation.
Please don't add this trace into an estimator manually. FastEstimator will add it automatically.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
monitor_names |
Set[str]
|
Any keys which should be collected over the course of an test epoch. |
required |
Source code in fastestimator/fastestimator/trace/trace.py
Trace
¶
Trace controls the training loop. Users can use the Trace
base class to customize their own functionality.
Traces are invoked by the fe.Estimator periodically as it runs. In addition to the current data dictionary, they are
also given a pointer to the current System
instance which allows access to more information as well as giving the
ability to modify or even cancel training. The order of function invocations is as follows:
Training: Testing:
on_begin on_begin
| |
on_epoch_begin (train) <------< on_epoch_begin (test) <------<
| | | |
on_batch_begin (train) <----< | on_batch_begin (test) <----< |
| | | | | |
on_batch_end (train) >-----^ | on_batch_end (test) >------^ |
| ^ | |
on_epoch_end (train) | on_epoch_end (test) >---------^
| | |
on_epoch_begin (eval) | on_end
| ^
on_batch_begin (eval) <----< |
| | |
on_batch_end (eval) >-----^ |
| |
on_epoch_end (eval) >----------^
|
on_end
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
Union[None, str, Iterable[str]]
|
A set of keys that this trace intends to read from the state dictionary as inputs. |
None
|
outputs |
Union[None, str, Iterable[str]]
|
A set of keys that this trace intends to write into the system buffer. |
None
|
mode |
Union[None, str, Iterable[str]]
|
What mode(s) to execute this Trace in. For example, "train", "eval", "test", or "infer". To execute regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument like "!infer" or "!train". |
None
|
ds_id |
Union[None, str, Iterable[str]]
|
What dataset id(s) to execute this Trace in. To execute regardless of ds_id, pass None. To execute in all ds_ids except for a particular one, you can pass an argument like "!ds1". |
None
|
Source code in fastestimator/fastestimator/trace/trace.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
get_outputs
¶
What outputs will be generated by this trace.
You can ignore this unless you are designing a new trace that has special interactions between its outputs and particular dataset ids.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds_ids |
Union[None, str, List[str]]
|
The ds_ids under which this trace will execute. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
The outputs of this trace. |
Source code in fastestimator/fastestimator/trace/trace.py
on_batch_begin
¶
Runs at the beginning of each batch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
A dictionary through which traces can communicate with each other or write values for logging. |
required |
on_batch_end
¶
Runs at the end of each batch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
The current batch and prediction data, as well as any information written by prior |
required |
on_begin
¶
Runs once at the beginning of training or testing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
A dictionary through which traces can communicate with each other or write values for logging. |
required |
on_end
¶
Runs once at the end training.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
A dictionary through which traces can communicate with each other or write values for logging. |
required |
on_epoch_begin
¶
Runs at the beginning of each epoch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
A dictionary through which traces can communicate with each other or write values for logging. |
required |
on_epoch_end
¶
Runs at the end of each epoch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
A dictionary through which traces can communicate with each other or write values for logging. |
required |
TrainEssential
¶
Bases: Trace
A trace to collect important information during training.
Please don't add this trace into an estimator manually. FastEstimator will add it automatically.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
monitor_names |
Set[str]
|
Which keys from the data dictionary to monitor during training. |
required |
Source code in fastestimator/fastestimator/trace/trace.py
parse_freq
¶
A helper function to convert string based frequency inputs into epochs or steps
Parameters:
Name | Type | Description | Default |
---|---|---|---|
freq |
Union[None, str, int]
|
One of either None, "step", "epoch", "#s", "#e", or #, where # is an integer. |
required |
Returns:
Type | Description |
---|---|
Freq
|
A |
Freq
|
frequency with which it should run. |
Source code in fastestimator/fastestimator/trace/trace.py
sort_traces
¶
Sort traces to attempt to resolve any dependency issues.
This is essentially a topological sort, but it doesn't seem worthwhile to convert the data into a graph representation in order to get the slightly better asymptotic runtime complexity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
traces |
List[Trace]
|
A list of traces (not inside schedulers) to be sorted. |
required |
ds_ids |
List[str]
|
The ds_ids currently available to the traces. |
required |
available_outputs |
Union[None, str, Set[str]]
|
What output keys are already available for the traces to use. If None are provided, the sorting algorithm will assume that any keys not generated by traces are being provided by the system. This results in a less rigorous sorting. |
None
|
Returns:
Type | Description |
---|---|
List[Trace]
|
The sorted list of |
Raises:
Type | Description |
---|---|
AssertionError
|
If Traces have circular dependencies or require input keys which are not available. |