PPYOLOE_pytorch icon indicating copy to clipboard operation
PPYOLOE_pytorch copied to clipboard

RuntimeError: torch.nn.functional.binary_cross_entropy and torch.nn.BCELoss are unsafe to autocast.

Open jasonaidm opened this issue 2 years ago • 1 comments

RuntimeError: torch.nn.functional.binary_cross_entropy and torch.nn.BCELoss are unsafe to autocast. Many models use a sigmoid layer right before the binary cross entropy layer. In this case, combine the two layers using torch.nn.functional.binary_cross_entropy_with_logits or torch.nn.BCEWithLogitsLoss. binary_cross_entropy_with_logits and BCEWithLogits are safe to autocast.

jasonaidm avatar Jul 07 '22 14:07 jasonaidm

Same issue. I set batch size to 1 and it is resolved

antecessor avatar Nov 08 '23 19:11 antecessor