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

Loss functions for classification - logits/probabilities (page 472) #29

Closed
labdmitriy opened this issue Mar 21, 2022 · 5 comments
Closed

Comments

@labdmitriy
Copy link

Hi Sebastian,

There is the same value on the picture on the page 472 for y_pred in the columns for probabilities (BCELoss) and logits (BCEWithLogitsLoss): 0.8
Probably the value for the first column (BCELoss) is 0.69, which is equal to sigmoid(0.8)?

Thank you.

@rasbt
Copy link
Owner

rasbt commented Mar 21, 2022

Thanks, again! Yeah, looking at it, it doesn't make sense to have the same values there. If we assume that the logits are 0.8, then the input for BCELoss should be 0.69.

Screen Shot 2022-03-21 at 9 43 55 AM

Or, vice versa, if we assume that the predicted class membership proba from calling sigmoid(y_pred) = 0.8, then the logits should be 1.386.

Screen Shot 2022-03-21 at 9 43 57 AM

Let me CC Hayden, who has the original figure. @haydenliu Can you update the figure and open a PR? Thanks!!

@labdmitriy
Copy link
Author

labdmitriy commented Mar 21, 2022

Probably y_pred=0.8 for BCEWithLogitsLoss is more consistent with the code you provided in the book on the same page (and the second row for multiclass classification is already consistent with the code):

logits = torch.tensor([0.8])
probas = torch.sigmoid(logits)

@rasbt
Copy link
Owner

rasbt commented Mar 21, 2022

Good point

@haydenliu
Copy link
Contributor

Thanks Dmitry and Seb.
Merge request: #33

@rasbt
Copy link
Owner

rasbt commented Mar 22, 2022

Thanks, just merged!

@rasbt rasbt closed this as completed Mar 22, 2022
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

3 participants