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

Why using log_softmax instead of softmax? #52

Open
nguyenvulong opened this issue Jul 4, 2022 · 1 comment
Open

Why using log_softmax instead of softmax? #52

nguyenvulong opened this issue Jul 4, 2022 · 1 comment

Comments

@nguyenvulong
Copy link

I think it should be softmax instead. Otherwise p_t and p_s are not comparable.

Could you please explain why?

def forward(self, y_s, y_t):
p_s = F.log_softmax(y_s/self.T, dim=1)
p_t = F.softmax(y_t/self.T, dim=1)
loss = F.kl_div(p_s, p_t, size_average=False) * (self.T**2) / y_s.shape[0]
return loss

@nguyenvulong
Copy link
Author

for those who have similar question like i did: yoshitomo-matsubara/torchdistill#233

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