From ca910abc5f50a559fa0769e1c21621464d25eaac Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 17 Jan 2023 12:01:55 +0100 Subject: Fix --- training/strategy/ti.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'training') diff --git a/training/strategy/ti.py b/training/strategy/ti.py index 1af834b..ba78b98 100644 --- a/training/strategy/ti.py +++ b/training/strategy/ti.py @@ -119,10 +119,11 @@ def textual_inversion_strategy_callbacks( def on_after_optimize(lr: float): if use_emb_decay: - text_encoder.text_model.embeddings.normalize( - emb_decay_target, - min(1.0, emb_decay * lr) - ) + with torch.no_grad(): + text_encoder.text_model.embeddings.normalize( + emb_decay_target, + min(1.0, emb_decay * lr) + ) if ema_embeddings is not None: ema_embeddings.step(text_encoder.text_model.embeddings.temp_token_embedding.parameters()) -- cgit v1.2.3-70-g09d2