diff options
author | Volpeon <git@volpeon.ink> | 2023-01-13 07:25:24 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2023-01-13 07:25:24 +0100 |
commit | 89d471652644f449966a0cd944041c98dab7f66c (patch) | |
tree | 4cc797369a5c781b4978b89a61023c4de7fde606 /models/clip | |
parent | Update (diff) | |
download | textual-inversion-diff-89d471652644f449966a0cd944041c98dab7f66c.tar.gz textual-inversion-diff-89d471652644f449966a0cd944041c98dab7f66c.tar.bz2 textual-inversion-diff-89d471652644f449966a0cd944041c98dab7f66c.zip |
Code deduplication
Diffstat (limited to 'models/clip')
-rw-r--r-- | models/clip/embeddings.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/models/clip/embeddings.py b/models/clip/embeddings.py index 46b414b..9a23a2a 100644 --- a/models/clip/embeddings.py +++ b/models/clip/embeddings.py | |||
@@ -99,12 +99,12 @@ class ManagedCLIPTextEmbeddings(CLIPTextEmbeddings): | |||
99 | 99 | ||
100 | return embeds | 100 | return embeds |
101 | 101 | ||
102 | def normalize(self, lambda_: float = 1.0): | 102 | def normalize(self, target: float = 0.4, lambda_: float = 1.0): |
103 | w = self.temp_token_embedding.weight | 103 | w = self.temp_token_embedding.weight |
104 | pre_norm = w[self.temp_token_ids, :].norm(dim=-1, keepdim=True) | 104 | pre_norm = w[self.temp_token_ids, :].norm(dim=-1, keepdim=True) |
105 | w[self.temp_token_ids] = F.normalize( | 105 | w[self.temp_token_ids] = F.normalize( |
106 | w[self.temp_token_ids, :], dim=-1 | 106 | w[self.temp_token_ids, :], dim=-1 |
107 | ) * (pre_norm + lambda_ * (0.4 - pre_norm)) | 107 | ) * (pre_norm + lambda_ * (target - pre_norm)) |
108 | 108 | ||
109 | def forward( | 109 | def forward( |
110 | self, | 110 | self, |