Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/diffusers/schedulers/scheduling_ddpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model.
trained_betas (`np.ndarray`, *optional*):
An array of betas to pass directly to the constructor without using `beta_start` and `beta_end`.
variance_type (`"fixed_small"`, `"fixed_small_log"`, `"fixed_large"`, `"fixed_large_log"`, `"learned"`, or `"learned_range"`, defaults to `"fixed_small"`):
Clip the variance when adding noise to the denoised sample.
variance_type (`"fixed_small"`, `"fixed_small_log"`, `"fixed_large"`, `"fixed_large_log"`, `"learned"`, `"learned_range"`, or `"zeros"`, defaults to `"fixed_small"`):
The type of variance to compute. If `None`, uses the variance type specified in the scheduler
configuration.
clip_sample (`bool`, defaults to `True`):
Clip the predicted sample for numerical stability.
clip_sample_range (`float`, defaults to `1.0`):
Expand Down Expand Up @@ -198,6 +199,7 @@ def __init__(
"fixed_large_log",
"learned",
"learned_range",
"zeros",
] = "fixed_small",
clip_sample: bool = True,
prediction_type: Literal["epsilon", "sample", "v_prediction"] = "epsilon",
Expand Down Expand Up @@ -553,6 +555,8 @@ def step(
elif self.variance_type == "learned_range":
variance = self._get_variance(t, predicted_variance=predicted_variance)
variance = torch.exp(0.5 * variance) * variance_noise
elif self.variance_type == "zeros":
variance = torch.zeros_like(pred_prev_sample)
else:
variance = (self._get_variance(t, predicted_variance=predicted_variance) ** 0.5) * variance_noise

Expand Down