PyTorch torch.softmax function
PyTorch torch reference manual
torch.softmax is a function in PyTorch used to compute the element-wise softmax function.
Function definition
torch.softmax(input, dim, dtype=None)
Usage examples
Example
import
torch
Compute softmax
x
=
torch.
tensor
(
[
1.0
,
2.0
,
3.0
]
)
result
=
torch.
softmax
(
x
,
dim
=
0
)
(
result
)