Rows That Sum to One
Return the softmax of each row of the 2-D tensor x: e raised to each element, divided by the sum of those for its row. Every row then holds positive numbers that add up to 1.
Example 1
x [[0.0,0.0]]
returns [[0.5,0.5]]
Constraints
- 1 to 5 rows, 1 to 5 columns
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Stack the RowsEasy
- The First GradientEasy
- The k LargestEasy
- A Moving AverageMedium
- Count the ParametersMedium
- Cross-EntropyMedium
- Fit a LineMedium
- How Often RightMedium