nn.BCEwithLogitLoss applies the sigmoid internally and calculates the loss given the logits as inputs. If you want to use the probabilities given by the model, you would have to apply the sigmoid manually.