FunctionRacerProblemsRace

One Hot

EasyPyTorchPython

labels holds class numbers from 0 to n - 1. Return a 2-D tensor with one row per label and n columns: all zeros, except for a 1 in the column of that label.

Example 1

labels [0,2,1]
n 3
returns [[1,0,0],[0,0,1],[0,1,0]]

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More PyTorch problems