Build the cosine noise schedule with num_steps timesteps, clip its betas at max_beta, and return the betas together with the cumulative product rebuilt from the clipped betas.
f(u)=cos2(1+su/T+s⋅2π),βt=min(1−f(t)f(t+1), βmax),αˉt=k=0∏t(1−βk)Here T is num_steps, s is the offset s, βmax is max_beta, and the timestep t runs from 0 to T−1. The function f is evaluated at the T+1 points u=0,1,…,T, and each beta compares two neighbouring points.
Return a dict with exactly the keys "betas" and "alpha_bars", where each value is a float64 NumPy array of shape (num_steps,) in timestep order.
Input: num_steps = 4, s = 0.008, max_beta = 0.999
Output: {"betas":[0.152988,0.416958,0.707859,0.999],"alpha_bars":[0.847012,0.493844,0.144272,0.000144]}
Explanation: The cosine curve gives alpha_bar ratios that turn into betas of about 0.153, 0.417 and 0.708, and the last raw beta is almost exactly 1, so it is clipped to 0.999 and the final alpha_bar becomes 0.144272 * 0.001.
Input: num_steps = 3, s = 0.008, max_beta = 0.5
Output: {"betas":[0.257116,0.5,0.5],"alpha_bars":[0.742884,0.371442,0.185721]}
Input: num_steps = 2, s = 0.0, max_beta = 0.999
Output: {"betas":[0.5,0.999],"alpha_bars":[0.5,0.0005]}
np.arange(num_steps + 1) / num_steps gives every value of u / T on the grid.
f[1:] / f[:-1] gives every neighbouring ratio at once.
np.minimum(raw, max_beta) clips every value from above at max_beta.
Call np.cumprod only after the betas are clipped.
Accepts: integer
Accepts: number
Accepts: number
Build the cosine noise schedule with num_steps timesteps, clip its betas at max_beta, and return the betas together with the cumulative product rebuilt from the clipped betas.
f(u)=cos2(1+su/T+s⋅2π),βt=min(1−f(t)f(t+1), βmax),αˉt=k=0∏t(1−βk)Here T is num_steps, s is the offset s, βmax is max_beta, and the timestep t runs from 0 to T−1. The function f is evaluated at the T+1 points u=0,1,…,T, and each beta compares two neighbouring points.
Return a dict with exactly the keys "betas" and "alpha_bars", where each value is a float64 NumPy array of shape (num_steps,) in timestep order.
Input: num_steps = 4, s = 0.008, max_beta = 0.999
Output: {"betas":[0.152988,0.416958,0.707859,0.999],"alpha_bars":[0.847012,0.493844,0.144272,0.000144]}
Explanation: The cosine curve gives alpha_bar ratios that turn into betas of about 0.153, 0.417 and 0.708, and the last raw beta is almost exactly 1, so it is clipped to 0.999 and the final alpha_bar becomes 0.144272 * 0.001.
Input: num_steps = 3, s = 0.008, max_beta = 0.5
Output: {"betas":[0.257116,0.5,0.5],"alpha_bars":[0.742884,0.371442,0.185721]}
Input: num_steps = 2, s = 0.0, max_beta = 0.999
Output: {"betas":[0.5,0.999],"alpha_bars":[0.5,0.0005]}
np.arange(num_steps + 1) / num_steps gives every value of u / T on the grid.
f[1:] / f[:-1] gives every neighbouring ratio at once.
np.minimum(raw, max_beta) clips every value from above at max_beta.
Call np.cumprod only after the betas are clipped.
Accepts: integer
Accepts: number
Accepts: number