2021-12-04 15:18:50 +08:00
|
|
|
|
mindspore.nn.WithLossCell
|
|
|
|
|
|
=========================
|
|
|
|
|
|
|
|
|
|
|
|
.. py:class:: mindspore.nn.WithLossCell(backbone, loss_fn)
|
|
|
|
|
|
|
|
|
|
|
|
包含损失函数的Cell。
|
|
|
|
|
|
|
|
|
|
|
|
封装 `backbone` 和 `loss_fn` 。此Cell接受数据和标签作为输入,并将返回损失函数作为计算结果。
|
|
|
|
|
|
|
2022-07-25 16:47:23 +08:00
|
|
|
|
参数:
|
|
|
|
|
|
- **backbone** (Cell) - 要封装的骨干网络。
|
|
|
|
|
|
- **loss_fn** (Cell) - 用于计算损失函数。
|
2021-12-04 15:18:50 +08:00
|
|
|
|
|
2022-07-25 16:47:23 +08:00
|
|
|
|
输入:
|
|
|
|
|
|
- **data** (Tensor) - shape为 :math:`(N, \ldots)` 的Tensor。
|
|
|
|
|
|
- **label** (Tensor) - shape为 :math:`(N, \ldots)` 的Tensor。
|
2021-12-04 15:18:50 +08:00
|
|
|
|
|
2022-07-25 16:47:23 +08:00
|
|
|
|
输出:
|
|
|
|
|
|
Tensor,loss值,其shape通常为 :math:`()` 。
|
2021-12-04 15:18:50 +08:00
|
|
|
|
|
2022-07-25 16:47:23 +08:00
|
|
|
|
异常:
|
|
|
|
|
|
- **TypeError** - `data` 或 `label` 的数据类型既不是float16也不是float32。
|
2021-12-04 15:18:50 +08:00
|
|
|
|
|
2022-01-22 14:32:07 +08:00
|
|
|
|
.. py:method:: backbone_network
|
|
|
|
|
|
:property:
|
|
|
|
|
|
|
|
|
|
|
|
获取骨干网络。
|
|
|
|
|
|
|
2022-07-25 16:47:23 +08:00
|
|
|
|
返回:
|
|
|
|
|
|
Cell,骨干网络。
|