ptrblck:

You could count the number of positive and negative pixels for your complete training dataset and use the average of these counts


Please sir, how can I achieve this?
I have computed the mean() of a given image, which gave the fraction of 1s in the image. Then, I summed up these values to obtain that of the whole training data. I passed the obtained value to pos_weight. but there was no improvement.