MCPcopy Index your code
hub / github.com/Royalvice/DocDiff / p_mean_variance

Method p_mean_variance

schedule/diffusionSample.py:53–62  ·  view source on GitHub ↗
(self, x_t, cond_, t)

Source from the content-addressed store, hash-verified

51 return extract(self.coeff1, t, x_t.shape) * x_t - extract(self.coeff2, t, x_t.shape) * eps
52
53 def p_mean_variance(self, x_t, cond_, t):
54 # below: only log_variance is used in the KL computations
55 var = torch.cat([self.posterior_var[1:2], self.betas[1:]])
56 #var = self.betas
57 var = extract(var, t, x_t.shape)
58 eps = self.model(torch.cat((x_t, cond_), dim=1), t)
59 # nonEps = self.model(x_t, t, torch.zeros_like(labels).to(labels.device))
60 # eps = (1. + self.w) * eps - self.w * nonEps
61 xt_prev_mean = self.predict_xt_prev_mean_from_eps(x_t, t, eps=eps)
62 return xt_prev_mean, var
63
64 def noisy_image(self, t, y):
65 """ Compute y_noisy according to (6) p15 of [2]"""

Callers 1

forwardMethod · 0.95

Calls 2

extractFunction · 0.85

Tested by

no test coverage detected