If you are only dealing with a single class, you could use this:
x = torch.zeros(5).long()
print(x)
> tensor([0, 0, 0, 0, 0])
y = F.one_hot(x, num_classes=1)
print(y)
> tensor([[1],
[1],
[1],
[1],
[1]])
Note, that I don’t think your use case is well defined. If you are dealing only with a single number of classes (class0), your model won’t be able to learn anything, as the only possible and right answer would be to predict a high probability for class0.
A simple methods such as:
def classify(input):
return 0
would yield a 100% accuracy.