torch.nn.LogSoftmax用法
阿新 • • 發佈:2020-12-22
LOGSOFTMAX
CLASS torch.nn.LogSoftmax(dim: Optional[int] = None)
將函式應用於n維輸入張量。 LogSoftmax公式可以簡化為:
Shape:
-
Input:(∗)where∗means, any number of additional dimensions
-
Output:(∗), same shape as the input
Parameters
dim(int) – A dimension along whichLogSoftmaxwill 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)