mindspore.ops.dense =================== .. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/br_base/resource/_static/logo_source.svg :target: https://gitee.com/mindspore/mindspore/blob/br_base/docs/api/api_python/ops/mindspore.ops.func_dense.rst :alt: 查看源文件 .. py:function:: mindspore.ops.dense(input, weight, bias=None) 对输入 `input` 应用全连接操作。全连接定义为: .. math:: output = input * weight^{T} + bias .. warning:: - 这是一个实验性API,后续可能修改或删除。 - 在Ascend硬件平台下,设置PYNATIVE或KBK模式时,如果 `bias` 不是1D, `input` 不可以大于6D。 参数: - **input** (Tensor) - 输入Tensor,shape是 :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。