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

logit_bias init for non siglip pretrained models #717

Conversation

rsomani95
Copy link
Contributor

Fixes #712

There's one awkward bit about this currently:

import open_clip, torch

m = open_clip.create_model("convnext_base_w", "laion_aesthetic_s13b_b82k", init_logit_bias=100)
m.logit_bias == torch.tensor(0.)   # Maybe this is ok, but this feels awkward?

@rwightman
Copy link
Collaborator

rwightman commented Oct 28, 2023

@rsomani95 I think it should be

    if 'logit_bias' not in state_dict and model.logit_bias is not None:
        state_dict["logit_bias"] = torch.tensor(0.)

EDIT: actually maybe state_dict["logit_bias"] = torch.zeros_like(state_dict["logit_scale"]) in case we allow loading state dict onto specific device or in diff precision in the future

@rwightman rwightman merged commit 5e6114e into mlfoundations:main Oct 31, 2023
1 of 5 checks passed
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

Successfully merging this pull request may close these issues.

Error When Loading Non SigLIP Pre-Trained Checkpoint To Train With Sigmoid Loss
2 participants