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

Bug? Always zero gradient for model.scale #7

Open
vadimkantorov opened this issue Aug 6, 2023 · 0 comments
Open

Bug? Always zero gradient for model.scale #7

vadimkantorov opened this issue Aug 6, 2023 · 0 comments

Comments

@vadimkantorov
Copy link

vadimkantorov commented Aug 6, 2023

Hi @ines-chami!

At https://github.com/HazyResearch/HypHC/blob/master/model/hyphc.py#L42 :

init_size=1e-3        # in config.py also "init_size": 1e-3
max_scale=1. - 1e-3   # in config.py also "max_scale": 1 - 1e-3
self.scale = nn.Parameter(torch.Tensor([init_size]), requires_grad=True)

min_scale = 1e-2 #self.init_size
max_scale = self.max_scale
return F.normalize(embeddings, p=2, dim=1) * self.scale.clamp_min(min_scale).clamp_max(max_scale)

So self.scale (initialized always to init_size = 1e-3) is always outside the clamp range (min_scale = 1e-2 and max_scale = 1 - 1e-3), and so always receives zero gradient.

Is it expected / by design or was it some debug setting min_scale = 1e-2 which by mistake was not removed?

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