sometimes
Sometimes
¶
Bases: NumpyOp
Perform a NumpyOp with a given probability.
Note that Sometimes should not be used to wrap an op whose output key(s) do not already exist in the data dictionary. This would result in a problem when future ops / traces attempt to reference the output key, but Sometimes declined to generate it. If you want to create a default value for a new key, simply use a LambdaOp before invoking the Sometimes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
numpy_op |
NumpyOp
|
The operator to be performed. |
required |
prob |
float
|
The probability of execution, which should be in the range: [0-1). |
0.5
|
Source code in fastestimator/fastestimator/op/numpyop/meta/sometimes.py
forward
¶
Execute the wrapped operator a certain fraction of the time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
List[ndarray]
|
The information to be passed to the wrapped operator. |
required |
state |
Dict[str, Any]
|
Information about the current execution context, for example {"mode": "train"}. |
required |
Returns:
Type | Description |
---|---|
Union[FilteredData, List[ndarray]]
|
The original |
Source code in fastestimator/fastestimator/op/numpyop/meta/sometimes.py
set_rua_level
¶
Set the augmentation intensity based on the magnitude_coef.
This method is specifically designed to be invoked by the RUA Op.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
magnitude_coef |
float
|
The desired augmentation intensity (range [0-1]). |
required |
Raises:
Type | Description |
---|---|
AttributeError
|
If the 'op' doesn't have a 'set_rua_level' method. |