Hi Shamoon!



 shamoons:

    pos_weight = zeros_sum / one_sum 

However, in certain batches, there are no one_sum examples for a particular class. How do I deal with pos_weight in those cases?


I would recommend (and would in general, not just for your case)
not computing pos_weight on a per-batch basis, but, instead,
use the pos_weight for your whole training set, or for a
representative sample of your training set.
In any event, your individual batches should be representative
of your whole training set.  They differ from one another randomly,
of course, but shouldn’t differ from one another systematically.
For example, you wouldn’t want to train on several batches of
mostly positive samples, and then train on batches of mostly
negative samples.
Best.
K. Frank