Hi @ptrblck  ,  i am having a similar problem i wonder if you could help me. It goes like this:
My target is a tensor torch.Size([731022, 1]) but my model returns torch.Size([1462044, 2])

imagem996×727 40.5 KB

And after i do this:
////////////////////////////////////////////////////////////////////////////////////////////////////////////
criterion = torch.nn.MSELoss()
optimizer = torch.optim.Adam(lstm1.parameters(), lr=learning_rate)
for epoch in range(num_epochs):
outputs = lstm1.forward(X_train_tensors_final) #forward pass
optimizer.zero_grad() #caluclate the gradient, manually setting to 0
loss = criterion(outputs, y_train_tensors)
loss.backward() #calculates the loss of the loss function
optimizer.step() #improve from loss, i.e backprop
if epoch % 1 == 0:
print(“Epoch: %d, loss: %1.5f” % (epoch, loss.item()))
///////////////////////////////////////////////////////////////////////////////////////////////
And the error i get is this:
UserWarning: Using a target size (torch.Size([731022, 1])) that is different to the input size (torch.Size([1462044, 2])). 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)
Now i know its returning the output, hn and cn but what i dont understand is why is it returning 1462044 values which is double the values of the input. I hope you can help me, thanks!