mindspore/docs/api/api_python/mint/mindspore.mint.nn.functiona...

28 lines
1.3 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.mint.nn.functional.linear
======================================
.. py:function:: mindspore.mint.nn.functional.linear(input, weight, bias=None)
对输入 `input` 应用全连接操作。全连接定义为:
.. math::
output = input * weight^{T} + bias
.. warning::
- 这是一个实验性API后续可能修改或删除。
- 在Ascend硬件平台下设置PYNATIVE或KBK模式时如果 `bias` 不是1D `input` 不可以大于6D。
参数:
- **input** (Tensor) - 输入Tensorshape是 :math:`(*, in\_channels)`,其中 :math:`*` 表示任意的附加维度。
- **weight** (Tensor) - 输入Tensor的权重shape是 :math:`(out\_channels, in\_channels)`:math:`(in\_channels)`
- **bias** (Tensor可选) - 添加在输出结果的偏差shape是 :math:`(out\_channels)`:math:`()`。默认值:``None`` 偏差为0。
返回:
输出结果shape由 `input``weight` 的shape决定。
异常:
- **TypeError** - `input` 不是Tensor。
- **TypeError** - `weight` 不是Tensor。
- **TypeError** - `bias` 不是Tensor。
- **RuntimeError** - 在Ascend硬件平台下设置PYNATIVE或KBK模式时 `bias` 不是1D且 `input` 大于6D。