diff options
-rw-r--r-- | training/functional.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/training/functional.py b/training/functional.py index 27527ef..b9574ec 100644 --- a/training/functional.py +++ b/training/functional.py | |||
@@ -314,10 +314,10 @@ def loss_step( | |||
314 | elif noise_scheduler.config.prediction_type == "v_prediction": | 314 | elif noise_scheduler.config.prediction_type == "v_prediction": |
315 | target = noise_scheduler.get_velocity(latents, noise, timesteps) | 315 | target = noise_scheduler.get_velocity(latents, noise, timesteps) |
316 | 316 | ||
317 | alpha_t = noise_scheduler.alphas_cumprod[timesteps].float()[..., None, None, None].expand(bsz, 1, 1, 1) | 317 | alpha_t = noise_scheduler.alphas_cumprod[timesteps].float() |
318 | snr = alpha_t / (1 - alpha_t) | 318 | snr = alpha_t / (1 - alpha_t) |
319 | snr /= snr + 1 | 319 | snr_weights = snr.fmin(torch.tensor([5], device=latents.device)) / (snr + 1) |
320 | snr_weights = snr.fmin(torch.tensor([5], device=latents.device)) | 320 | snr_weights = snr_weights[..., None, None, None] |
321 | else: | 321 | else: |
322 | raise ValueError(f"Unknown prediction type {noise_scheduler.config.prediction_type}") | 322 | raise ValueError(f"Unknown prediction type {noise_scheduler.config.prediction_type}") |
323 | 323 | ||