Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.softmax function

PyTorch torch.softmax function


PyTorch torch reference manual 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

)

print

(

result

)


PyTorch torch reference manual PyTorch torch reference manual