评价此页

Softmin#

class torch.nn.modules.activation.Softmin(dim=None)[源代码]#

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

重新缩放输入 so that the elements of the n-dimensional output Tensor lie in the range [0, 1] and sum to 1.

Softmin 定义为

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

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

参数

dim (int) – A dimension along which Softmin will be computed (so every slice along dim will sum to 1).

返回

a Tensor of the same dimension and shape as the input, with values in the range [0, 1]

返回类型

示例

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

返回模块的额外表示。

返回类型

str

forward(input)[源代码]#

执行前向传播。

返回类型

张量