2022-05-27 14:23:35 +08:00
|
|
|
|
mindspore.nn.probability.bnn_layers.WithBNNLossCell
|
|
|
|
|
|
===================================================
|
|
|
|
|
|
|
|
|
|
|
|
.. py:class:: mindspore.nn.probability.bnn_layers.WithBNNLossCell(backbone, loss_fn, dnn_factor=1, bnn_factor=1)
|
|
|
|
|
|
|
2022-07-01 10:49:56 +08:00
|
|
|
|
为 BNN 生成一个合适的 WithLossCell,用损失函数包装贝叶斯网络。
|
2022-05-27 14:23:35 +08:00
|
|
|
|
|
2022-07-18 15:22:30 +08:00
|
|
|
|
参数:
|
|
|
|
|
|
- **backbone** (Cell) - 目标网络。
|
|
|
|
|
|
- **loss_fn** (Cell) - 用于计算损失的损失函数。
|
|
|
|
|
|
- **dnn_factor** (int, float) - backbone 的损失系数,由损失函数计算。默认值:1。
|
|
|
|
|
|
- **bnn_factor** (int, float) - KL 损失系数,即贝叶斯层的 KL 散度。默认值:1。
|
2022-05-27 14:23:35 +08:00
|
|
|
|
|
2022-07-18 15:22:30 +08:00
|
|
|
|
输入:
|
|
|
|
|
|
- **data** (Tensor) - `data` 的 shape :math:`(N, \ldots)`。
|
|
|
|
|
|
- **label** (Tensor) - `label` 的 shape :math:`(N, \ldots)`。
|
2022-05-27 14:23:35 +08:00
|
|
|
|
|
2022-07-18 15:22:30 +08:00
|
|
|
|
输出:
|
|
|
|
|
|
Tensor,任意 shape 的标量 Tensor。
|
2022-05-27 14:23:35 +08:00
|
|
|
|
|
|
|
|
|
|
.. py:method:: backbone_network
|
|
|
|
|
|
:property:
|
|
|
|
|
|
|
2022-07-01 10:49:56 +08:00
|
|
|
|
返回backbone_network。
|
2022-05-27 14:23:35 +08:00
|
|
|
|
|
2022-07-18 15:22:30 +08:00
|
|
|
|
返回:
|
|
|
|
|
|
Cell,backbone_network。
|