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

Whether to reuse the Sigmoid function in the confidence loss calculation code? #89

Open
EATMustard opened this issue Jun 5, 2024 · 1 comment

Comments

@EATMustard
Copy link

EATMustard commented Jun 5, 2024

Pytorch.BCEWithLogitsLoss performs the Sigmoid operation, but the Sigmoid is reused in the model code. Is this a bug?

class TokenConfidence(nn.Module):

def __init__(self, dim: int) -> None:

    super().__init__()

    self.token = nn.Sequential(nn.Linear(dim, 1), nn.Sigmoid())  # sigmoid once

    self.loss_fn = nn.BCEWithLogitsLoss(reduction="none")  # sigmoid twice 
@noahzn
Copy link

noahzn commented Aug 6, 2024

I think this is a bug, I tried removing nn.Sigmoid in self.token and adding torch.sigmoid in forward(), but the results are almost the same. Have you tried?

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

2 participants