We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
easy
primitives
Implement One-Hot Encoding
Implement one-hot encoding.
Convert integer class labels into one-hot vectors. Each label $i$ becomes a vector of length num_classes with 1 at position $i$ and 0 everywhere else.
Input:
-
labels: 1D integer tensor of shape(N,)with values in $[0, \text{num\_classes})$ -
num_classes: total number of classes
Output: 2D tensor of shape (N, num_classes) with one-hot encoding
Hints
encoding
classification
basics
Sign in to attempt this problem and view the solution.