mindspore/docs/api/api_python/nn/mindspore.nn.WithEvalCell.rst

26 lines
841 B
ReStructuredText
Raw Normal View History

2021-12-04 15:18:50 +08:00
mindspore.nn.WithEvalCell
=========================
.. py:class:: mindspore.nn.WithEvalCell(network, loss_fn, add_cast_fp32=False)
封装前向网络和损失函数,返回用于计算评估指标的损失函数值、前向输出和标签。
**参数:**
2021-12-04 20:36:47 +08:00
- **network** (Cell) - 前向网络。
- **loss_fn** (Cell) - 损失函数。
2021-12-04 15:18:50 +08:00
- **add_cast_fp32** (bool)是否将数据类型调整为float32。默认值False。
**输入:**
- **data** Tensor - shape为 :math:`(N, \ldots)` 的Tensor。
- **label** Tensor - shape为 :math:`(N, \ldots)` 的Tensor。
**输出:**
Tuple(Tensor)包括标量损失函数、shape为 :math:`(N, \ldots)` 的网络输出和shape为 :math:`(N, \ldots)` 的标签。
**异常:**
**TypeError** `add_cast_fp32` 不是bool。