kevinzakka / pytorch-goodies

PyTorch Boilerplate For Research
603 stars 71 forks source link

One hot encoding #12

Open ashnair1 opened 4 years ago

ashnair1 commented 4 years ago

I had a question about how one hot encoding is done.

Why is it done like this:

true_1_hot = torch.eye(num_classes + 1)[true.squeeze(1)]

when it could be implemented like this

true_1_hot = F.one_hot(true, num_classes + 1)

Am I missing something or was F.one_hot added later?