You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.L1Regularizer.rst 907 B

1234567891011121314151617181920212223242526272829303132
  1. mindspore.nn.L1Regularizer
  2. ===========================
  3. .. py:class:: mindspore.nn.L1Regularizer(scale)
  4. 对权重计算L1正则化。
  5. .. math::
  6. \text{loss}=\lambda * \text{reduce_sum}(\text{abs}(\omega))
  7. :math:`\lambda` 代表 `scale` 。
  8. .. note::
  9. 正则化因子应为大于0。
  10. **参数:**
  11. - **scale** (int, float) - L1正则化因子,其值大于0。
  12. **输入:**
  13. - **weights** (Tensor) - L1Regularizer的输入,任意维度的Tensor,数据类型为float16或float32。
  14. **输出:**
  15. Tensor,其shape为(),默认数据类型为mindspore.float32,如果权重的数据类型精度更高,则以权重的数据类型作为输出数据类型。
  16. **异常:**
  17. - **TypeError** - `scale` 既不是int也不是float。
  18. - **ValueError** - `scale` 不大于0。
  19. - **ValueError** - `scale` 是math.inf或math.nan。