Unit 5 - Exercise 1 #40
-
Dear Mr. Raschka, I changed the classifier to a regression model and got the warning that the shape of the logits differ from that of the true_labels so the mse_loss results could be wrong. after that I changed the loss to: Now I don't get the Warning and have reasonable results. I only wanted to ask if that solution is right or did I make a mistake? Thanks for answering my question Johannes |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi there, on the one hand, there is nothing wrong with what you do, but on the other hand, I wonder why you need the |
Beta Was this translation helpful? Give feedback.
Hello,
thanks for your reply.
That's the error message:
UserWarning: Using a target size (torch.Size([32])) that is different to the input size (torch.Size([32, 1])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
loss = F.mse_loss(logits, true_labels)
This suggests that the logits have two dimension as the true_labels only have one dimension. This is confirmed when I look at the Tensors so I flattend the one with two dimensions and solved the error message. I only wondered if that leads to errors which I haven't seen yet.
My Outputlayer receives 5 features and gives 1 value out as I'm doing a regression task.