torch.nn.LogSoftmax用法

LOGSOFTMAX

CLASS torch.nn.LogSoftmax(dim: Optional[int] = None)

\large log(Softmax(x))函数应用于n维输入张量。 LogSoftmax公式可以简化为:

\large \text{LogSoftmax}(x_{i}) = \log\left(\frac{\exp(x_i) }{ \sum_j \exp(x_j)} \right)

Shape:

  • Input: (∗) where ∗ means, any number of additional dimensions

  • Output: (∗) , same shape as the input

Parameters

dim (int) – A dimension along which LogSoftmax will be computed.用来计算LogSoftmax的维度。

Returns

a Tensor of the same dimension and shape as the input with values in the range [-inf, 0)。与输入具有相同维度和形状的张量,其值在[-inf,0)范围内。

Examples:

>>> m = nn.LogSoftmax()
>>> input = torch.randn(2, 3)
>>> output = m(input)

你可能感兴趣的:(Pytorch,pytorch,LogSoftmax)