I don’t understand why you want to do this kind of replacement, since these are two functions commonly used for different kind of problems : classification vs regression.
But if you want, you can just give an acceptable shape to your tensors : this by using a single neuron at the last layer, so that logits will be compatible with label in terms of dimension.