評價此頁

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]#

執行前向傳播。

返回型別

張量