If you are dealing with multi-label classification sigmoid + nn.BCELoss should be what you are looking for; and if you are looking for multi-class classification (each of your sample will belong to only one of the 20 classes) then softmax + nn.CrossEntropyLoss are the things.