Skip to content

Commit

Permalink
clamp comment @sayakpaul
Browse files Browse the repository at this point in the history
  • Loading branch information
williamberman committed Apr 10, 2023
1 parent 1875c35 commit 0cbefef
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/diffusers/schedulers/scheduling_ddpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def _get_variance(self, t, predicted_variance=None, variance_type=None):
# and sample from it to get previous sample
# x_{t-1} ~ N(pred_prev_sample, variance) == add variance to pred_sample
variance = (1 - alpha_prod_t_prev) / (1 - alpha_prod_t) * current_beta_t

# we always take the log of variance, so clamp it to ensure it's not 0
variance = torch.clamp(variance, min=1e-20)

if variance_type is None:
Expand Down

0 comments on commit 0cbefef

Please sign in to comment.