mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #46] Temperature Clipping Missing #40
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#40
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @KeremTurgutlu on GitHub (Feb 20, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/46
Thanks for the amazing work and open sourcing it!
In the paper it is mentioned:
However, I am not able to find logits clipping in model.py, in this section:
Is this a possible change to the code that might refer to the paper?:
Though I am not sure how gradients would behave with
torch.clamp, like an issue here.Also, shouldn't initial temperature be
0.07according to the paper? In the following code1=1/temperatureif I am not mistaken?Maybe to this?
@jongwook commented on GitHub (Feb 20, 2021):
That's correct. The released code was rewritten for simpler inference usage, and it's missing a few details on training. For clipping the
logit_scalevalue, I'd check its value right afteroptimizer.step()in the training loop and assignlog(100)if it's over that number.Appending
*(1/0.07)might prevent the pytorch module to identify that as a learnable parameter. You could add a line likenn.init.constant_(self.logit_scale, np.log(1/0.07)), or simplynn.Parameter(torch.tensor([np.log(1/0.07)])).@Meteorix commented on GitHub (Mar 9, 2021):
or simply
nn.Parameter(torch.tensor([np.log(1/0.07)]))? @jongwook@jongwook commented on GitHub (Mar 9, 2021):
yeah you're correct- thanks for catching that! I'll edit the comment above to avoid any future confusion
@KeremTurgutlu commented on GitHub (Mar 9, 2021):
Yeah, I ended adding these two lines: line 1 for init and line 2 for clipping. FYI, I implemented training as a fastai callback. Also added, few missing details like gradient checkpointing too.
@Horizon2333 commented on GitHub (Oct 17, 2021):
Can I ask you some questions about learnable temperature? I found it quickly grow to the upper bound in order to reduce log-softmax loss. So its performance is worse than fixed value of temperature? Have you found something like this?
@ghost commented on GitHub (Jan 28, 2022):
Hum, is it even useful when the batch sizes are relatively smaller? the higher
temperature kind of smooths out the predictions, which kind of prevents it from overfitting to the "label".