Is my assumption correct that you are trying to predict three different classes?
If so, you could convert your target tensor containing the class indices into a one-hot encoded target using:
nb_classes = 3
target = torch.empty(1, 24, 24, dtype=torch.long).random_(nb_classes)
target = torch.zeros(1, nb_classes, 24, 24).scatter_(1, target.unsqueeze(1), 1)