mindspore2022/docs/api/api_python/nn/mindspore.nn.L1Regularizer.rst

32 lines
907 B
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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