General question

My output layer has 2 neurons, and doing binary classification.
The sigmoid output from the hidden player outputs a n rows and 2 columns shape.
The target labels are in format [0,1,0…1] format.
When calculating the loss function, should I be converting probabilities from the sigmoid output less than 0.5 to class 1 and more than 0.5 to class 0.
Or calculate the loss directly using the probability and the target label?
Thanks

You should keep the probabilities as they are when inputting them in the loss function with their target. Moreover, if you are doing binary classification, you only need one neuron as your end layer (either it’s 1 or 0). Another quick tip: don’t use the sigmoid function as the output of your nn model. Leave the output as it is and use torch.nn.BCEWithLogitsLoss as the loss function. It directly intergrates the sigmoid function and has better numerical stability.

1 Like