torch.nn.functional.huber_loss¶
- torch.nn.functional.huber_loss(input, target, reduction='mean', delta=1.0, weight=None) Tensor [source]¶
Computes the Huber loss, with optional weighting.
Function uses a squared term if the absolute element-wise error falls below delta and a delta-scaled L1 term otherwise.
When delta equals 1, this loss is equivalent to SmoothL1Loss. In general, Huber loss differs from SmoothL1Loss by a factor of delta (AKA beta in Smooth L1).
- Parameters
input (Tensor) – Predicted values.
target (Tensor) – Ground truth values.
reduction (str, optional) – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘mean’: the mean of the output is taken. ‘sum’: the output will be summed. ‘none’: no reduction will be applied. Default: ‘mean’.
delta (float, optional) – The threshold at which to change between delta-scaled L1 and L2 loss. Default: 1.0.
weight (Tensor, optional) – Weights for each sample. Default: None.
- Returns
Huber loss (optionally weighted).
- Return type