Hi,
Few things, Variable is deprecated ince 0.4
I’m wondering couple of things:
What is loss_type sigmoid? Sigmoid is an activation/function not a loss. You shouldn’t round
Why do you use pos_weight = torch.ones([class_count]) It doesn’t make sense at all to me.
Have a look at docs about it. https://pytorch.org/docs/stable/nn.html?highlight=bcewithlogits#torch.nn.BCEWithLogitsLoss 2
Lastly, you shouldn’t use round and casting types. Even if you ideally want your output to be binary, at the training time outputs have to cover an interval. They cannot be binary.
Lastly, L1 is not usually the best way if you can use other losses.
Why do you have
            elif losstype == 'cross_entropy' or losstype == 'sigmoid':
                loss = F.l1_loss(output.round(), target)

But then you use l1 instead?