Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit b896388

Browse files
Update softmax.md
1 parent 463afff commit b896388

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • content/pytorch/concepts/tensor-operations/terms/softmax

content/pytorch/concepts/tensor-operations/terms/softmax/softmax.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The Softmax function for an element $x_i$ in a vector $x$ is defined as:
1919

2020
$$\text{Softmax}(x_{i}) = \frac{\exp(x_i)}{\sum_{j} \exp(x_j)}$$
2121

22-
By exponentiating the inputs, the function ensures all outputs are non-negative. By dividing by the sum of these exponentials, it ensures that the resulting values sum to exactly 1.
22+
By exponentiating the inputs, the function ensures all outputs are non-negative. Dividing by the sum of these exponentials ensures that the resulting values sum to exactly 1.
2323

2424
## Syntax
2525

@@ -30,7 +30,7 @@ torch.softmax(input, dim, dtype=None)
3030
**Parameters:**
3131

3232
- `input`: The input tensor containing the raw scores (logits).
33-
- `dim`: A dimension along which Softmax will be computed. Every slice along dim will sum to 1.
33+
- `dim`: A dimension along which Softmax will be computed. Every slice along the dim will sum to `1`.
3434
- `dtype` (Optional): The desired data type of the returned tensor.
3535

3636
**Return value:**
@@ -62,7 +62,7 @@ Probabilities: tensor([0.0900, 0.2447, 0.6652])
6262
Sum of probabilities: 1.0
6363
```
6464

65-
The function converts raw logits into probabilities where the highest input value (3.0) yields the highest probability (~0.66), and the sum of all probabilities equals 1.0.
65+
The function converts raw logits into probabilities where the highest input value (3.0) yields the highest probability (~0.66), and the sum of all probabilities equals `1.0`.
6666

6767
## Example 2: Softmax on a 2D Tensor
6868

@@ -94,4 +94,4 @@ Probabilities:
9494
Sum of each row: tensor([1.0000, 1.0000])
9595
```
9696

97-
By specifying `dim=1`, the operation is applied independently to each row (sample), ensuring that the class probabilities for each individual sample sum to 1.0.
97+
By specifying `dim=1`, the operation is applied independently to each row (sample), ensuring that the class probabilities for each individual sample sum to `1.0`.

0 commit comments

Comments
 (0)