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.LossBase
- ======================
-
- .. py:class:: mindspore.nn.LossBase(reduction='mean')
-
- 构建损失函数的基类。
-
- 自定义损失函数时应实现自己的 `construct` ,并使用方法 `self.get_loss` 将reduction应用于loss计算。
-
- **参数:**
-
- - **reduction** (str) -指定应用于输出结果的计算方式。可选值有:"mean"、"sum"、"none"。默认值:"mean"。
-
- **异常:**
-
- - **ValueError** - `reduction` 不为'none'、'mean'或'sum'。
-
-
- .. py:method:: get_axis(x)
-
- 获取输入的轴范围。
-
- **参数:**
-
- - **x** (Tensor) - 任何shape的Tensor。
-
-
- .. py:method:: get_loss(x, weights=1.0)
-
- 计算加权损失。
-
- **参数:**
-
- - **x** (Tensor) - 输入数据,任意维度的Tensor。
- - **weights** (Union[float, Tensor]) - 可选值,要么rank为0,要么rank与输入相同,并且必须可广播到输入(即,所有维度必须为 `1` ,或与相应输入的维度相同)。
|