CrossEntropyLoss is used for a multi-class classification and expects the model output to have the shape [batch_size, nb_classes] and the target [batch_size] containing the class indices.
In your case the last linear layer has a single output unit, which would define nb_classes = 1.
Your target might therefore only contain zeros?
In this setup your model won’t learn anything, as it only needs to output a high value for the single output unit to predict the “right” class0.
Could you explain your use case a bit, i.e. how many classes are you dealing with and what does target contain?