評價此頁

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)[原始碼]#

執行前向傳播。

返回型別

張量