SmoothL1Loss¶
- class
dragon.vm.torch.nn.
SmoothL1Loss
(
beta=1.0,
size_average=None,
reduce=None,
reduction='mean'
)[source]¶ Compute the element-wise error transited from L1 and L2. [Girshick, 2015].
The SmoothL1Loss function is defined as:
\[\text{SmoothL1Loss}(x, y) = \begin{cases} 0.5 * (x - y)^{2} / beta, & \text{ if } |x - y| < beta \\ |x - y| - 0.5 * beta, & \text{ otherwise } \end{cases} \]Examples:
m = torch.nn.SmoothL1Loss(beta=0.11) loss = m(torch.ones(2, 3), torch.zeros(2, 3))
__init__¶
SmoothL1Loss.
__init__
(
beta=1.0,
size_average=None,
reduce=None,
reduction='mean'
)[source]¶Create a
SmoothL1Loss
module.- Parameters:
- beta (float, optional, default=1.) – The transition point from L1 to L2 loss
- size_average (bool, optional) –
True
to set thereduction
to ‘mean’. - reduce (bool, optional) –
True
to set thereduction
to ‘sum’ or ‘mean’. - reduction ({'none', 'mean', 'sum'}, optional) – The reduce method.