The k Largest
Return the k largest elements of the 1-D tensor x, the largest first.
Example 1
x [3.0,9.0,1.0,7.0]
k 2
returns [9.0,7.0]
Constraints
- 1 to 8 elements, all different
1 <= k <=the number of elements
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- A Moving AverageMedium
- Count the ParametersMedium
- Cross-EntropyMedium
- Fit a LineMedium
- How Often RightMedium
- In BatchesMedium
- Many OutputsMedium
- Mean Squared ErrorMedium