评价此页

Softmin#

class torch.nn.Softmin(dim=None)[source]#

对 n 维输入 Tensor 应用 Softmin 函数。

重新调整它们,使得 n 维输出 Tensor 的元素位于 [0, 1] 范围内并求和为 1。

Softmin 定义为

Softmin(xi)=exp(xi)jexp(xj)\text{Softmin}(x_{i}) = \frac{\exp(-x_i)}{\sum_j \exp(-x_j)}
形状
  • 输入: ()(*),其中 * 表示任意数量的附加维度

  • 输出: ()(*),与输入形状相同

参数

dim (a Tensor of the same dimension and shape as the input, with values in the range [0, 1]) – 沿 Softmin 计算的维度(因此沿 dim 的每个切片将求和为 1)。

返回

一个与输入具有相同维度和形状的 Tensor,其值在 [0, 1] 范围内

返回类型

示例

>>> m = nn.Softmin(dim=1)
>>> input = torch.randn(2, 3)
>>> output = m(input)
extra_repr()[source]#

返回模块的额外表示。

返回类型

str

forward(input)[source]#

执行前向传播。

返回类型

张量