(self, s=0.001)
| 8 | self.schedule = schedule |
| 9 | |
| 10 | def cosine_beta_schedule(self, s=0.001): |
| 11 | timesteps = self.timesteps |
| 12 | steps = timesteps + 1 |
| 13 | x = torch.linspace(0, timesteps, steps) |
| 14 | alphas_cumprod = torch.cos(((x / timesteps) + s) / (1 + s) * np.pi * 0.5) ** 2 |
| 15 | alphas_cumprod = alphas_cumprod / alphas_cumprod[0] |
| 16 | betas = 1 - (alphas_cumprod[1:] / alphas_cumprod[:-1]) |
| 17 | return torch.clip(betas, 0.0001, 0.9999) |
| 18 | |
| 19 | def linear_beta_schedule(self): |
| 20 | timesteps = self.timesteps |