I would like to know how to obtain the probability predictions for each class in a multilabel classification with fastai. I understand that the predictions generated by fastai are in a matrix n rows X m columns where the columns are the classes and rows represent predictions for all n images. How can I convert these numbers into something that represents the probability for each class? Based on the pytorch documentation for the loss function BCEWithLogitsLoss, it appears to be just np.exp( - predictions)? Can someone explain how the loss function and the predictions are generated in more detail?

If you’re using BCEWithLogitsLoss, you should run the output through a sigmoid to get probabilities.

Can you explain why I should run the output through a sigmoid function based on the formula given? The formula provided in the pytorch documentation is this:

BCEWithLogitsLoss combines a sigmoid with binary cross entropy loss. So in order to get output values between 0 and 1 like you want, you have to apply a sigmoid to the output of your network.

The formula you posted is the formula for binary cross entropy, but with sigmoid (represented by the sigma symbol) applied to x_n.