So for binary image classification this is how it should be done i feel. Correct me if i am wrong.
Input= [batch_size, channels, height,width]
predicted_mask = [batch_size, 1, height, width]
gt_mask = [batch_size, 1, height, width]
Assuming your data has 25% positive pixels and 75% negative pixels. Then a good weight value will be 75/25 = 3
positive_weight = torch.ones([1])*3.0
loss = nn.BCEWithLogitsLoss(pos_weight=positive_weight)
My only confusion is do i need to have extra one dimension for class or it doesn’t matter ?
predicted_mask = [batch_size, 1, height, width] OR  [batch_size, height, width]
gt_mask = [batch_size, 1, height, width] OR  [batch_size, height, width]