(alphacums, ddim_timesteps, eta, verbose=True)
| 61 | |
| 62 | |
| 63 | def make_ddim_sampling_parameters(alphacums, ddim_timesteps, eta, verbose=True): |
| 64 | # select alphas for computing the variance schedule |
| 65 | alphas = alphacums[ddim_timesteps] |
| 66 | alphas_prev = np.asarray([alphacums[0]] + alphacums[ddim_timesteps[:-1]].tolist()) |
| 67 | |
| 68 | # according the the formula provided in https://arxiv.org/abs/2010.02502 |
| 69 | sigmas = eta * np.sqrt((1 - alphas_prev) / (1 - alphas) * (1 - alphas / alphas_prev)) |
| 70 | if verbose: |
| 71 | print(f'Selected alphas for ddim sampler: a_t: {alphas}; a_(t-1): {alphas_prev}') |
| 72 | print(f'For the chosen value of eta, which is {eta}, ' |
| 73 | f'this results in the following sigma_t schedule for ddim sampler {sigmas}') |
| 74 | return sigmas, alphas, alphas_prev |
| 75 | |
| 76 | |
| 77 | def betas_for_alpha_bar(num_diffusion_timesteps, alpha_bar, max_beta=0.999): |
no outgoing calls
no test coverage detected