MCPcopy Create free account
hub / github.com/CompVis/diff2flow / make_ddim_sampling_parameters

Function make_ddim_sampling_parameters

diff2flow/ddim.py:37–49  ·  view source on GitHub ↗
(alphacums, ddim_timesteps, eta, verbose=True)

Source from the content-addressed store, hash-verified

35
36
37def make_ddim_sampling_parameters(alphacums, ddim_timesteps, eta, verbose=True):
38 # select alphas for computing the variance schedule
39 alphas = alphacums[ddim_timesteps]
40 alphas_prev = np.asarray([alphacums[0]] + alphacums[ddim_timesteps[:-1]].tolist())
41
42 # according the the formula provided in https://arxiv.org/abs/2010.02502
43 sigmas = eta * np.sqrt((1 - alphas_prev) / (1 - alphas) * (1 - alphas / alphas_prev))
44 if verbose:
45 print(f'Selected alphas for ddim sampler: a_t: {alphas}; a_(t-1): {alphas_prev}')
46 print(f'For the chosen value of eta, which is {eta}, '
47 f'this results in the following sigma_t schedule for ddim sampler {sigmas}')
48
49 return sigmas, alphas, alphas_prev
50
51
52class DDIMSampler:

Callers 1

make_scheduleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected