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

Method inverse_lambda

schedule/dpm_solver_pytorch.py:159–175  ·  view source on GitHub ↗

Compute the continuous-time label t in [0, T] of a given half-logSNR lambda_t.

(self, lamb)

Source from the content-addressed store, hash-verified

157 return log_mean_coeff - log_std
158
159 def inverse_lambda(self, lamb):
160 """
161 Compute the continuous-time label t in [0, T] of a given half-logSNR lambda_t.
162 """
163 if self.schedule == 'linear':
164 tmp = 2. * (self.beta_1 - self.beta_0) * torch.logaddexp(-2. * lamb, torch.zeros((1,)).to(lamb))
165 Delta = self.beta_0**2 + tmp
166 return tmp / (torch.sqrt(Delta) + self.beta_0) / (self.beta_1 - self.beta_0)
167 elif self.schedule == 'discrete':
168 log_alpha = -0.5 * torch.logaddexp(torch.zeros((1,)).to(lamb.device), -2. * lamb)
169 t = interpolate_fn(log_alpha.reshape((-1, 1)), torch.flip(self.log_alpha_array.to(lamb.device), [1]), torch.flip(self.t_array.to(lamb.device), [1]))
170 return t.reshape((-1,))
171 else:
172 log_alpha = -0.5 * torch.logaddexp(-2. * lamb, torch.zeros((1,)).to(lamb))
173 t_fn = lambda log_alpha_t: torch.arccos(torch.exp(log_alpha_t + self.cosine_log_alpha_0)) * 2. * (1. + self.cosine_s) / math.pi - self.cosine_s
174 t = t_fn(log_alpha)
175 return t
176
177
178def model_wrapper(

Calls 1

interpolate_fnFunction · 0.85

Tested by

no test coverage detected