I have pretty much same problem. I have class imbalance of 8:1,
I tried using BCE Loss with different weights i.e.

[0.75, 1.25] seems working a bit well but got stuck at the end.
[0.5, 2.5] model diverged sooner.
(Optimizer ASGD with LR 0.01)

I used ADAM first, but it didn’t behave nicely so I switched to ASGD.
Is it necessary to have the sum of weights == 1? (if yes, may you please explain why?)
this is my loss function:
def weighted_binary_cross_entropy(output, target, weights=None):
    output = torch.clamp(output,min=1e-8,max=1-1e-8)

    if weights is not None:
        assert len(weights) == 2
        loss = weights[1] * (target * torch.log(output)) + \
               weights[0] * ((1 - target) * torch.log(1 - output))
    else:
        loss = target * torch.log(output) + (1 - target) * torch.log(1 - output)

    return torch.neg(torch.mean(loss))