Quadratic Beta Schedule
Problem Statement
Besides the linear schedule, early DDPM code offered a quadratic beta schedule: the square roots of the betas are linearly spaced. Build it.
Background
A quadratic schedule places sqrt(beta_t) on a linear grid from sqrt(beta_start) to sqrt(beta_end) across T steps, then squares:
This keeps the earliest betas smaller than a linear schedule, adding noise more gently at first.
Your Task
Implement:
def quadratic_beta_schedule(T, beta_start, beta_end):
Return a list of T betas rounded to 6 decimals.
Input Format
- T (int): number of steps, T >= 2.
- beta_start, beta_end (float): endpoints, 0 < beta_start < beta_end < 1.
Output Format
- A list of T floats rounded to 6 decimals.
Sample
print(quadratic_beta_schedule(3, 0.0001, 0.04))
Output:
[0.0001, 0.011025, 0.04]
Example
print(quadratic_beta_schedule(3, 0.0001, 0.04))
[0.0001, 0.011025, 0.04]
- Compute the square roots of the endpoints to establish the linear range for the schedule: and .
- Determine the step size for the linear spacing across steps: .
- Generate the linearly spaced values for the square roots of the betas:
- :
- :
- :
- Square each value to obtain the actual beta values:
- The final output is [0.0001, 0.011025, 0.04]
Constraints
T >= 2,0 < beta_start < beta_end < 1.- Linearly space the square roots, then square.
- Round every beta to 6 decimals.