MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / betas_for_alpha_bar

Function betas_for_alpha_bar

ldm/modules/diffusionmodules/util.py:77–93  ·  view source on GitHub ↗

Create a beta schedule that discretizes the given alpha_t_bar function, which defines the cumulative product of (1-beta) over time from t = [0,1]. :param num_diffusion_timesteps: the number of betas to produce. :param alpha_bar: a lambda that takes an argument t from 0 to 1 and

(num_diffusion_timesteps, alpha_bar, max_beta=0.999)

Source from the content-addressed store, hash-verified

75
76
77def betas_for_alpha_bar(num_diffusion_timesteps, alpha_bar, max_beta=0.999):
78 """
79 Create a beta schedule that discretizes the given alpha_t_bar function,
80 which defines the cumulative product of (1-beta) over time from t = [0,1].
81 :param num_diffusion_timesteps: the number of betas to produce.
82 :param alpha_bar: a lambda that takes an argument t from 0 to 1 and
83 produces the cumulative product of (1-beta) up to that
84 part of the diffusion process.
85 :param max_beta: the maximum beta to use; use values lower than 1 to
86 prevent singularities.
87 """
88 betas = []
89 for i in range(num_diffusion_timesteps):
90 t1 = i / num_diffusion_timesteps
91 t2 = (i + 1) / num_diffusion_timesteps
92 betas.append(min(1 - alpha_bar(t2) / alpha_bar(t1), max_beta))
93 return np.array(betas)
94
95
96def extract_into_tensor(a, t, x_shape):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected