I have a tensor of size 16 x 28 where 16 is batch size and 28 is sentence length. Every element of the sentence vectors are some index (0 to n). I want to create a 16 x 28 x n tensor where the vectors in 3rd dimension will be one hot encoding of the index which means I want to put 1 in the specified index and rest of the values will be zero. How can I do that using pytorch functionalities?
Right now, I am doing this with loop but I want to avoid looping!