Hi,
I tried to implement BCEWithLogitsLoss by myself.
for example,
def bce_loss(pred, target):
    pred=F.sigmoid(pred)
    loss=torch.mean(-torch.sum(target * torch.log(pred) + (1-target) * torch.log(1-pred)) / target.size(1))

however, the loss is quite larger than torch.nn.BCEWithLogitsLoss
for example,
def bce_loss_pytorch(pred, target):
    m=torch.nn.BCEWithLogitsLoss()
    loss=m(pred, target)

I am not sure what is the main difference between my implementation and torch.nn.BCEWithLogitsLoss.
any idea?