Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WS02 - Question 2 - Swapping cross entropy loss for MSE loss #5

Open
Aseamann opened this issue Feb 7, 2025 · 0 comments
Open

WS02 - Question 2 - Swapping cross entropy loss for MSE loss #5

Aseamann opened this issue Feb 7, 2025 · 0 comments

Comments

@Aseamann
Copy link

Aseamann commented Feb 7, 2025

Swapping to MSE loss is not directly intuitive. MSEloss in PyTorch takes labels that are one-hot encoded as default. To do this, I generated a separate variable "y_onehot". It may be helpful to clarify this in a "hint" box or something along with this question.

# one hot encode y
y_onehot = torch.nn.functional.one_hot(y, num_classes=3)
y_onehot = y_onehot.type(torch.float32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant