Tornike:

Thanks a lot.


No problem.
I just want to quickly summarize everything for you, in order to not confuse you.

Your network outputs, so called, logits, that are not in range 0-1.


These logits can be put into a 0-1 range by either passing them trough a nn.Sigmoid() layer at the end of your net, or by passing the logits through torch.sigmoid().


If you use nn.BCELoss as your loss, you need the nn.Sigmoid() layer at the end of your net. But it is recommended to use nn.BCEWithLogitsLoss as your loss and not have a nn.Sigmoid() layer at the end of your net.


When using the recommended nn.BCEWithLogitsLoss, torch.sigmoid() is used during testing/interference. Since nn.BCEWithLogitsLoss takes in logits you build your net to output logits, but during testing/interference we want the 0-1 probability so we pass the nets logits through torch.sigmoid().

Hope this helps