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

Function stratified_uniform

train_single.py:173–182  ·  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

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

Callers 1

rand_cosine_interpolatedFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected