The error can be raised if you are passing the model output or target as a BoolTensor to nn.BCEWithLogitsLoss as seen here:
criterion = nn.BCEWithLogitsLoss()
output = torch.randn(10, 1, requires_grad=True)
target = torch.randint(0, 2, (10, 1)).float()
# works
loss = criterion(output, target)
# fails
loss = criterion(output, target.bool())
# RuntimeError: Subtraction, the `-` operator, with two bool tensors is not supported. Use the `^` or `logical_xor()` operator instead.
loss = criterion(output.bool(), target)
# RuntimeError: Negation, the `-` operator, on a bool tensor is not supported. If you are trying to invert a mask, use the `~` or `logical_not()` operator instead.
Based on the error message it seems the target tensor is a BoolTensor so check how it’s created and make sure it’s a floating point tensor using the same dtype as the model output.