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

23 lines
855 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)
2022-09-06 16:52:57 +08:00
封装前向网络和损失函数。
返回用于计算评估指标的损失函数值、前向输出和标签。
2021-12-04 15:18:50 +08:00
参数:
- **network** (Cell) - 前向网络。
- **loss_fn** (Cell) - 损失函数。
2022-08-04 15:00:55 +08:00
- **add_cast_fp32** (bool) - 是否将数据类型调整为float32。默认值False。
2021-12-04 15:18:50 +08:00
输入:
- **data** Tensor - shape为 :math:`(N, \ldots)` 的Tensor。
- **label** Tensor - shape为 :math:`(N, \ldots)` 的Tensor。
2021-12-04 15:18:50 +08:00
输出:
Tuple(Tensor)包括标量损失函数、shape为 :math:`(N, \ldots)` 的网络输出和shape为 :math:`(N, \ldots)` 的标签。
2021-12-04 15:18:50 +08:00
异常:
- **TypeError** - `add_cast_fp32` 不是bool。