MCPcopy Create free account
hub / github.com/Royalvice/DocDiff / cosine_beta_schedule

Method cosine_beta_schedule

schedule/schedule.py:10–17  ·  view source on GitHub ↗
(self, s=0.001)

Source from the content-addressed store, hash-verified

8 self.schedule = schedule
9
10 def cosine_beta_schedule(self, s=0.001):
11 timesteps = self.timesteps
12 steps = timesteps + 1
13 x = torch.linspace(0, timesteps, steps)
14 alphas_cumprod = torch.cos(((x / timesteps) + s) / (1 + s) * np.pi * 0.5) ** 2
15 alphas_cumprod = alphas_cumprod / alphas_cumprod[0]
16 betas = 1 - (alphas_cumprod[1:] / alphas_cumprod[:-1])
17 return torch.clip(betas, 0.0001, 0.9999)
18
19 def linear_beta_schedule(self):
20 timesteps = self.timesteps

Callers 1

get_betasMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected