sefibk / KernelGAN

Other
340 stars 77 forks source link

'float' object has no attribute 'size' #3

Closed Alpkant closed 4 years ago

Alpkant commented 4 years ago

When i execute training command given in README on the custom dataset of jpeg images, following error arises:

 UserWarning: Using a target size (torch.Size([13])) that is different to the input size (torch.Size([1, 1, 13, 13])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
  return F.l1_loss(input, target, reduction=self.reduction)
nn/functional.py", line 2152, in l1_loss
    if not (target.size() == input.size()):
AttributeError: 'float' object has no attribute 'size'

Is this due to images or implementation error?

xyc2690 commented 4 years ago

You are using a higher version of Pytorch. Try to replace the '1.' with 'torch.Tensor(1)'. In the file 'loss.py': line 60: return self.loss(1., torch.sum(kernel))

sefibk commented 4 years ago

@xyc2690 - thank you! I updated 'loss.py' accordingly with an extra '.to(kernel.device)' to verify the device. Let me know if it still does not work