MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / stratified_uniform

Function stratified_uniform

k_diffusion/utils.py:268–277  ·  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

266
267
268def stratified_uniform(shape, group=0, groups=1, dtype=None, device=None):
269 """Draws stratified samples from a uniform distribution."""
270 if groups <= 0:
271 raise ValueError(f"groups must be positive, got {groups}")
272 if group < 0 or group >= groups:
273 raise ValueError(f"group must be in [0, {groups})")
274 n = shape[-1] * groups
275 offsets = torch.arange(group, n, groups, dtype=dtype, device=device)
276 u = torch.rand(shape, dtype=dtype, device=device)
277 return (offsets + u) / n
278
279
280stratified_settings = threading.local()

Callers 1

stratified_with_settingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected