MCPcopy Create free account
hub / github.com/Francis-Rings/StableAnimator / stratified_uniform

Function stratified_uniform

train.py:172–181  ·  view source on GitHub ↗

Draws stratified samples from a uniform distribution.

(shape, group=0, groups=1, dtype=None, device=None)

Source from the content-addressed store, hash-verified

170
171# copy from https://github.com/crowsonkb/k-diffusion.git
172def stratified_uniform(shape, group=0, groups=1, dtype=None, device=None):
173 """Draws stratified samples from a uniform distribution."""
174 if groups <= 0:
175 raise ValueError(f"groups must be positive, got {groups}")
176 if group < 0 or group >= groups:
177 raise ValueError(f"group must be in [0, {groups})")
178 n = shape[-1] * groups
179 offsets = torch.arange(group, n, groups, dtype=dtype, device=device)
180 u = torch.rand(shape, dtype=dtype, device=device)
181 return (offsets + u) / n
182
183
184def rand_cosine_interpolated(shape, image_d, noise_d_low, noise_d_high, sigma_data=1., min_value=1e-3, max_value=1e3, device='cpu', dtype=torch.float32):

Callers 1

rand_cosine_interpolatedFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected