LogSoftmax¶
- class torch.nn.LogSoftmax(dim=None)[source][source]¶
將 函式應用於 n 維輸入 Tensor。
LogSoftmax 公式可以簡化為
- 形狀
輸入: 其中 * 表示任意數量的附加維度
輸出: ,與輸入形狀相同
- 引數
dim (int) – 計算 LogSoftmax 的維度。
- 返回值
一個與輸入具有相同維度和形狀的 Tensor,其值在 [-inf, 0) 範圍內
- 返回型別
None
示例
>>> m = nn.LogSoftmax(dim=1) >>> input = torch.randn(2, 3) >>> output = m(input)