mindspore/docs/api/api_python/probability/mindspore.nn.probability.bn...

36 lines
2.6 KiB
ReStructuredText
Raw Normal View History

2022-05-27 14:23:35 +08:00
mindspore.nn.probability.bnn_layers.DenseReparam
================================================
.. py:class:: mindspore.nn.probability.bnn_layers.DenseReparam(in_channels, out_channels, activation=None, has_bias=True, weight_prior_fn=NormalPrior, weight_posterior_fn=normal_post_fn, bias_prior_fn=NormalPrior, bias_posterior_fn=normal_post_fn)
具有重构参数化的密集变分层。
更多相关信息,请参阅论文 `自动编码变分贝叶斯 <https://arxiv.org/abs/1312.6114>`_
将密集连接层应用于输入。该层将操作实现为:
.. math::
\text{outputs} = \text{activation}(\text{inputs} * \text{weight} + \text{bias}),
在本公式中 :math:`\text{activation}` 是作为激活参数传递的激活函数(如果传入,:math:`\text{activation}` 是与创建层的输入具有相同数据类型的权重矩阵,
weight 是从权重的后验分布采样的权重矩阵,并且 bias 是与层创建的输入具有相同数据类型的偏置向量(仅当 has_bias 为 True 时)。偏差向量是从后验分布中采样的 bias。
**参数:**
- **in_channels** (int) 输入通道的数量。
- **out_channels** (int) 输出通道的数量。
- **activation** (str, Cell) 应用于层输出的正则化函数。激活的类型可以是 str例如'relu')或 Cell例如nn.ReLU())。注意,如果激活的类型是 Cell则必须事先实例化。默认值None。
- **has_bias** (bool) - 指定层是否使用偏置向量。默认值false。
- **weight_prior_fn** (Cell) - 权重的先验分布。它必须返回一个 mindspore 分布实例。默认值NormalPrior。创建标准正态分布的一个实例。当前版本仅支持正态分布。
- **weight_posterior_fn** (function) - 采样权重的后验分布。它必须是一个函数句柄,它返回一个 mindspore 分布实例。默认值normal_post_fn。当前版本仅支持正态分布。
- **bias_prior_fn** (Cell) - 偏置向量的先验分布。它必须返回一个 mindspore 分布实例。默认值NormalPrior创建标准正态分布的实例。当前版本仅支持正态分布。
- **bias_posterior_fn** (function) 采样偏差向量的后验分布。它必须是一个函数句柄,它返回一个 mindspore 分布实例。默认值normal_post_fn。当前版本仅支持正态分布。
**输入:**
- **input** (Tensor) - `input` 的 shape 是 :math:`(N, in\_channels)`
**输出:**
2022-06-10 08:30:45 +08:00
Tensor`output` 的 shape 是 :math:`(N, out\_channels)`