diff options
Diffstat (limited to 'models/clip')
-rw-r--r-- | models/clip/embeddings.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/models/clip/embeddings.py b/models/clip/embeddings.py index 9a23a2a..1cc59d9 100644 --- a/models/clip/embeddings.py +++ b/models/clip/embeddings.py | |||
@@ -100,6 +100,9 @@ class ManagedCLIPTextEmbeddings(CLIPTextEmbeddings): | |||
100 | return embeds | 100 | return embeds |
101 | 101 | ||
102 | def normalize(self, target: float = 0.4, lambda_: float = 1.0): | 102 | def normalize(self, target: float = 0.4, lambda_: float = 1.0): |
103 | if lambda_ == 0: | ||
104 | return | ||
105 | |||
103 | w = self.temp_token_embedding.weight | 106 | w = self.temp_token_embedding.weight |
104 | pre_norm = w[self.temp_token_ids, :].norm(dim=-1, keepdim=True) | 107 | pre_norm = w[self.temp_token_ids, :].norm(dim=-1, keepdim=True) |
105 | w[self.temp_token_ids] = F.normalize( | 108 | w[self.temp_token_ids] = F.normalize( |