From c0065a693073f65d5fd50e75978bc78a1c234771 Mon Sep 17 00:00:00 2001 From: Peilin Wang Date: Wed, 16 Sep 2020 11:26:35 -0400 Subject: [PATCH] change sigma to beta and update doc fix ci fix ci --- mindspore/nn/loss/loss.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mindspore/nn/loss/loss.py b/mindspore/nn/loss/loss.py index cc0e0fcab6d..b3042bfebe1 100644 --- a/mindspore/nn/loss/loss.py +++ b/mindspore/nn/loss/loss.py @@ -158,16 +158,16 @@ class SmoothL1Loss(_Loss): .. math:: L_{i} = \begin{cases} - 0.5 (x_i - y_i)^2, & \text{if } |x_i - y_i| < \text{sigma}; \\ - |x_i - y_i| - 0.5, & \text{otherwise. } + \frac{0.5 (x_i - y_i)^{2}}{\text{beta}}, & \text{if } |x_i - y_i| < \text{beta} \\ + |x_i - y_i| - 0.5 \text{beta}, & \text{otherwise. } \end{cases} - Here :math:`\text{sigma}` controls the point where the loss function changes from quadratic to linear. + Here :math:`\text{beta}` controls the point where the loss function changes from quadratic to linear. Its default value is 1.0. :math:`N` is the batch size. This function returns an unreduced loss Tensor. Args: - sigma (float): A parameter used to control the point where the function will change from + beta (float): A parameter used to control the point where the function will change from quadratic to linear. Default: 1.0. Inputs: @@ -183,10 +183,10 @@ class SmoothL1Loss(_Loss): >>> target_data = Tensor(np.array([1, 2, 2]), mindspore.float32) >>> loss(input_data, target_data) """ - def __init__(self, sigma=1.0): + def __init__(self, beta=1.0): super(SmoothL1Loss, self).__init__() - self.sigma = sigma - self.smooth_l1_loss = P.SmoothL1Loss(self.sigma) + self.beta = beta + self.smooth_l1_loss = P.SmoothL1Loss(self.beta) def construct(self, base, target): return self.smooth_l1_loss(base, target)