MCPcopy Create free account
hub / github.com/Zhiyuan-R/Tiger-Diffusion / _extract

Method _extract

train_generation.py:140–149  ·  view source on GitHub ↗

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

(a, t, x_shape)

Source from the content-addressed store, hash-verified

138
139 @staticmethod
140 def _extract(a, t, x_shape):
141 """
142 Extract some coefficients at specified timesteps,
143 then reshape to [batch_size, 1, 1, 1, 1, ...] for broadcasting purposes.
144 """
145 bs, = t.shape
146 assert x_shape[0] == bs
147 out = torch.gather(a, 0, t)
148 assert out.shape == torch.Size([bs])
149 return torch.reshape(out, [bs] + ((len(x_shape) - 1) * [1]))
150
151
152

Callers 5

q_mean_varianceMethod · 0.95
q_sampleMethod · 0.95
p_mean_varianceMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected