I’m segmenting foreground vs background using unet and there are many more 0s than 1s due to this. It looks like    i should be using BCEWithLogitsLoss as my loss function?
It looks like this function takes as an argument the proportion of class imbalance - “pos_weight (Tensor, optional) – a weight of positive examples. Must be a vector with length equal to the number of classes.”
Does that mean i need to know across all my images how many pixels are 1 v 0  If so is there any best practice on how to do this?
I do have some images that are pure “background” without any 1s in as part of the dataset, so an alternative is i could use pos_weight as the number of positive vs negative at a global scale?
Thanks