LogSoftmax¶
- class torch.nn.LogSoftmax(dim=None)[源代码]¶
将 函数应用于一个 n 维输入张量。
LogSoftmax 的公式可以简化为:
- Shape:
输入: 其中 * 表示任意数量的额外维度
输出: , 与输入形状相同
- Parameters
dim (int) – 计算LogSoftmax的维度。
- Returns
与输入具有相同维度和形状的张量,其值在范围 [-inf, 0) 内
- Return type
无
示例:
>>> m = nn.LogSoftmax(dim=1) >>> input = torch.randn(2, 3) >>> output = m(input)