andrewgcodes / xlstm

my attempts at implementing various bits of Sepp Hochreiter's new xLSTM architecture
MIT License
122 stars 8 forks source link

y_pred, y_true shape, are different: loss.py:535: UserWarning: Using a target size (torch.Size([1, 1])) that is different to the input size (torch.Size([10, 1])). #4

Open mw66 opened 3 months ago

mw66 commented 3 months ago

site-packages/torch/nn/modules/loss.py:535: UserWarning: Using a target size (torch.Size([1, 1])) that is different to the input size (torch.Size([10, 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)

If we set break point, and print out the y_pred, y_true shape, you can see they are different:

> /test/python/mLSTM.py(87)<module>()
-> loss += criterion(y_pred, y_true)
(Pdb) p y_pred.shape
torch.Size([10, 1])
(Pdb) p y_true.shape
torch.Size([1, 1])
(Pdb) 
mw66 commented 3 months ago

I think the line need to be fixed as:

        loss += criterion(y_pred[0], y_true[0])