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
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
|
Source code in fastestimator\fastestimator\trace\trace.py
30 31 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 |
|
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
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 |
available_outputs |
Optional[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. |