Hi,
I am working on regressing a score (positive real value) from images, and thus, the structure is almost identical to pytorch’s training a classifier example 7 except for a few parts including the change from CrossEntropyLoss() to MSELoss(). The input size to CNN is [4, 2, 240, 240] where 4 is the batch size, 3 is the channel size, and 240x240 is the image size. The output from CNN (i.e., from outputs = net(inputs)) is [4,1] because I set the last linear layer as nn.Linear(84, 1) in order to receive a single value. I may be doing wrong. Please let me know if including the entire code might be helpful for this issue. Thanks!
UserWarning: Using a target size (torch.Size([4, 1, 1])) that is different to the input size (torch.Size([4, 1])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
  return F.mse_loss(input, target, reduction=self.reduction)