You should CrossEntropyLoss for the other case also. In general, whenever you have a classification problem you should use CrossEntropyLoss due to various statistical reasons. BCEWithLogitsLoss is not suitable for that purpose. It is generally used in auto-encoders when you want to compare the reconstruction to the original image.