I am using the pytorch implementation of focal loss (sigmoid_focal_loss — Torchvision main documentation), but I am not sure how to compute the alpha weight.

It says: “Weighting factor in range (0,1) to balance positive vs negative examples or -1 for ignore.” and the authors say: it can be set by inverse class frequency.

How do I compute the class frequency? I have [36413, 8291] samples for class 0 and 1, respectively.

Thank you.