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

Function extract

schedule/diffusionSample.py:14–21  ·  view source on GitHub ↗

Extract some coefficients at specified timesteps, then reshape to [batch_size, 1, 1, 1, 1, ...] for broadcasting purposes.

(v, t, x_shape)

Source from the content-addressed store, hash-verified

12
13
14def extract(v, t, x_shape):
15 """
16 Extract some coefficients at specified timesteps, then reshape to
17 [batch_size, 1, 1, 1, 1, ...] for broadcasting purposes.
18 """
19 device = t.device
20 out = torch.gather(v, index=t, dim=0).float().to(device)
21 return out.view([t.shape[0]] + [1] * (len(x_shape) - 1))
22
23
24class GaussianDiffusion(nn.Module):

Callers 2

p_mean_varianceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected