l1_loss
L1_Loss
¶
Bases: LossOp
Calculate the L1 loss between two tensors.
This LossOp can be used to Implement
L1 loss: Is a criterion that calculates Mean Absolute Error between the elements ([y_pred, y_true]). Smooth_L1 loss: Is a criterion that uses squared loss if absolute element wise subtraction (y_pred - y_true) is less than 'beta' and vanilla L1 loss otherwise. Huber loss: Is a criterion that uses squared loss if absolute element wise subtraction (y_pred - y_true) is less than 'beta' and a 'beta' scaled L1 loss otherwise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs |
Union[Tuple[str, str], List[str]]
|
A tuple or list like: [y_pred, y_true]. |
required |
outputs |
str
|
String key under which to store the computed loss. |
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". |
'!infer'
|
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
|
average_loss |
bool
|
Whether to average the element-wise loss after the Loss Op. |
True
|
loss_type |
str
|
What type of L1 loss. Can either be 'L1' (L1 Loss), 'Smooth' (Smooth L1 Loss) or 'Huber' (Huber loss). Default:'L1' |
'L1'
|
beta |
Union[None, float]
|
A threshold at which to change between L1 and L2 loss. Needs to be a positive number. Default:1.0 . dtype: float16 or float32. |
1.0
|