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 873 B

123456789101112131415161718192021222324252627282930
  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. .. note::
  8. 正则化因子应为大于0。
  9. **参数:**
  10. - **scale** (int, float) - L1正则化因子,其值大于0。
  11. **输入:**
  12. - **weights** (Tensor) - L1Regularizer的输入,任意维度的Tensor,数据类型为float16或float32。
  13. **输出:**
  14. Tensor,其shape为(),默认数据类型为mindspore.float32,如果权重的数据类型精度更高,则以权重的数据类型作为输出数据类型。
  15. **异常:**
  16. - **TypeError** - `scale` 既不是int也不是float。
  17. - **ValueError** - `scale` 不大于0。
  18. - **ValueError** - `scale` 是math.inf或math.nan。