MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / cosine_beta_schedule

Function cosine_beta_schedule

usr/diff/shallow_diffusion_tts.py:175–185  ·  view source on GitHub ↗

cosine schedule as proposed in https://openreview.net/forum?id=-NEXDKk8gZ

(timesteps, s=0.008)

Source from the content-addressed store, hash-verified

173
174
175def 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
188beta_schedule = {

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected