cosine schedule as proposed in https://openreview.net/forum?id=-NEXDKk8gZ
(timesteps, s=0.008)
| 173 | |
| 174 | |
| 175 | def cosine_beta_schedule(timesteps, s=0.008): |
| 176 | """ |
| 177 | cosine schedule |
| 178 | as proposed in https://openreview.net/forum?id=-NEXDKk8gZ |
| 179 | """ |
| 180 | steps = timesteps + 1 |
| 181 | x = np.linspace(0, steps, steps) |
| 182 | alphas_cumprod = np.cos(((x / steps) + s) / (1 + s) * np.pi * 0.5) ** 2 |
| 183 | alphas_cumprod = alphas_cumprod / alphas_cumprod[0] |
| 184 | betas = 1 - (alphas_cumprod[1:] / alphas_cumprod[:-1]) |
| 185 | return np.clip(betas, a_min=0, a_max=0.999) |
| 186 | |
| 187 | |
| 188 | beta_schedule = { |