Only the Positives
Return the elements of the 1-D tensor x that are greater than 0, in the order they come.
Example 1
x [1.5,-2.0,0.0,3.0]
returns [1.5,3.0]
Constraints
- 1 to 8 elements
- Some may be exactly 0: those are left out
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Rows That Sum to OneEasy
- Stack the RowsEasy
- The First GradientEasy
- The k LargestEasy
- A Moving AverageMedium
- Count the ParametersMedium
- Cross-EntropyMedium
- Fit a LineMedium