ZJULearning / MaxSquareLoss

Code for "Domain Adaptation for Semantic Segmentation with Maximum Squares Loss" in PyTorch.
MIT License
113 stars 22 forks source link

IW_MaxSquareloss #15

Open dadafan2343 opened 3 years ago

dadafan2343 commented 3 years ago

Hello,

Thanks for your contribution and work. But I have the problem of "IW_MaxSquareloss":

"IW_MaxSquareloss" error: for: loss = -torch.sum((torch.pow(prob, 2)weights)[mask]) / (batch_sizeself.num_class)

torch.pow(prob, 2) and weights

RuntimeError: The size of tensor a (4) must match the size of tensor b (2) at non-singleton dimension 1

sonnefred commented 3 years ago

Hi, have you solved the problem, I met the same error...

junha1125 commented 2 years ago

weights means the weight values to be applied to each pixel of the label(width, hight)

So, I tried below to fix the error

weights = weights.repeat(19,1,1,1).transpose(0,1)  ## add this line
loss = -torch.sum((torch.pow(prob, 2)*weights)[mask]) / (batch_size*self.num_class)

Is it right?? How do you think about it??