numpyop
Batch
¶
Bases: NumpyOp
Convert data instances into a batch of data.
Only one instance of a Batch Op can be present for a given epoch/mode/ds_id combination. Any Ops after this one will operate on batches of data rather than individual instances (using their batch_forward methods).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_size |
Optional[int]
|
The batch size to use. If set, this will override any value specified by the Pipeline, allowing control of the batch size on a per-mode and per-ds_id level. Note that this value will be ignored when using a BatchDataset (or any dataset which decides on its own batch configuration). |
None
|
drop_last |
bool
|
Whether to drop the last batch if the last batch is incomplete. Note that setting this to True when using a BatchDataset (or any dataset which decides on its own batch configuration) won't do anything. |
False
|
pad_value |
Optional[Union[int, float]]
|
The padding value if batch padding is needed. None indicates that no padding is needed. Mutually
exclusive with |
None
|
collate_fn |
Optional[Callable[[List[Dict[str, Any]]], Dict[str, Any]]]
|
A function to merge a list of data elements into a batch of data. Mutually exclusive with
|
None
|
mode |
Union[None, str, Iterable[str]]
|
What mode(s) to execute this Op 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 Op 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/op/numpyop/numpyop.py
Delete
¶
Bases: NumpyOp
Delete key(s) and their associated values from the data dictionary.
The system has special logic to detect instances of this Op and delete its inputs
from the data dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keys |
Union[str, Sequence[str]]
|
Existing key(s) to be deleted from the data dictionary. |
required |
mode |
Union[None, str, Iterable[str]]
|
What mode(s) to execute this Op 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 Op 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/op/numpyop/numpyop.py
LambdaOp
¶
Bases: NumpyOp
An Operator that performs any specified function as forward function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn |
Callable
|
The function to be executed. |
required |
inputs |
Union[None, str, Iterable[str]]
|
Key(s) from which to retrieve data from the data dictionary. |
None
|
outputs |
Union[None, str, Iterable[str]]
|
Key(s) under which to write the outputs of this Op back to the data dictionary. |
None
|
mode |
Union[None, str, Iterable[str]]
|
What mode(s) to execute this Op 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 Op 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/op/numpyop/numpyop.py
set_rua_level
¶
A method which will be invoked by the RUA Op to adjust the augmentation intensity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
magnitude_coef |
float
|
The desired augmentation intensity (range [0-1]). |
required |
Source code in fastestimator/fastestimator/op/numpyop/numpyop.py
NumpyOp
¶
Bases: Op
An Operator class which takes and returns numpy data.
These Operators are used in fe.Pipeline to perform data pre-processing / augmentation. They may also be used in fe.Network to perform postprocessing on data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
Union[None, str, Iterable[str]]
|
Key(s) from which to retrieve data from the data dictionary. |
None
|
outputs |
Union[None, str, Iterable[str]]
|
Key(s) under which to write the outputs of this Op back to the data dictionary. |
None
|
mode |
Union[None, str, Iterable[str]]
|
What mode(s) to execute this Op 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 Op 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/op/numpyop/numpyop.py
forward
¶
A method which will be invoked in order to transform data.
This method will be invoked on individual elements of data before any batching / axis expansion is performed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Union[ndarray, List[ndarray]]
|
The arrays from the data dictionary corresponding to whatever keys this Op declares as its |
required |
state |
Dict[str, Any]
|
Information about the current execution context, for example {"mode": "train"}. |
required |
Returns:
Type | Description |
---|---|
Union[None, FilteredData, ndarray, List[ndarray]]
|
The |
Union[None, FilteredData, ndarray, List[ndarray]]
|
dictionary based on whatever keys this Op declares as its |
Source code in fastestimator/fastestimator/op/numpyop/numpyop.py
forward_batch
¶
A method which will be invoked in order to transform a batch of data.
This method will be invoked on batches of data during network postprocessing. It should expect to receive batched data and should itself return batched data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Union[ndarray, List[ndarray]]
|
The arrays from the data dictionary corresponding to whatever keys this Op declares as its |
required |
state |
Dict[str, Any]
|
Information about the current execution context, for example {"mode": "train"}. |
required |
Returns:
Type | Description |
---|---|
Union[None, FilteredData, ndarray, List[ndarray]]
|
The |
Union[None, FilteredData, ndarray, List[ndarray]]
|
dictionary based on whatever keys this Op declares as its |
Source code in fastestimator/fastestimator/op/numpyop/numpyop.py
RemoveIf
¶
Bases: NumpyOp
An Operator which will remove a datapoint from the pipeline if the given criterion is satisfied.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn |
Callable[..., bool]
|
A function taking any desired |
required |
replacement |
bool
|
Whether to replace the filtered element with another (thus maintaining the number of steps in an
epoch but potentially increasing data repetition) or else shortening the epoch by the number of filtered
data points (fewer steps per epoch than expected, but no extra data repetition). Either way, the number of
data points within an individual batch will remain the same. Even if |
True
|
inputs |
Union[None, str, Iterable[str]]
|
Key(s) from which to retrieve data from the data dictionary. |
None
|
mode |
Union[None, str, Iterable[str]]
|
What mode(s) to execute this Op 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 Op 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/op/numpyop/numpyop.py
forward_numpyop
¶
Call the forward function for list of NumpyOps, and modify the data dictionary in place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ops |
List[NumpyOp]
|
A list of NumpyOps to execute. |
required |
data |
MutableMapping[str, Any]
|
The data dictionary. |
required |
state |
Dict[str, Any]
|
Information about the current execution context, ex. {"mode": "train"}. Must contain at least the mode. |
required |
batched |
Optional[str]
|
Whether the |
None
|
shared |
bool
|
Whether you want to place the resulting data into multi-processing shared memory. Only applicable when
|
True
|