torch.nn.Softmax()
This performs a softmax on the given dimension.
The general formula for softmax is shown in Figure
B-22
(K is the number of
Here is the parameter:
• dim: The dimension to compute softmax along, determined by some
integer
Default = None.
You can define this as a layer within the model itself, or apply softmax in the forward
function like so:
torch.nn.functional.softmax(input, dim=None, _stacklevel=3)
appendix B intro to pytorch
Figure
shows an example of how you can use this layer in the forward function.