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

Function rand_split_log_normal

k_diffusion/utils.py:379–386  ·  view source on GitHub ↗

Draws samples from a split lognormal distribution.

(shape, loc, scale_1, scale_2, device='cpu', dtype=torch.float32)

Source from the content-addressed store, hash-verified

377
378
379def rand_split_log_normal(shape, loc, scale_1, scale_2, device='cpu', dtype=torch.float32):
380 """Draws samples from a split lognormal distribution."""
381 n = torch.randn(shape, device=device, dtype=dtype).abs()
382 u = torch.rand(shape, device=device, dtype=dtype)
383 n_left = n * -scale_1 + loc
384 n_right = n * scale_2 + loc
385 ratio = scale_1 / (scale_1 + scale_2)
386 return torch.where(u < ratio, n_left, n_right).exp()
387
388
389class FolderOfImages(data.Dataset):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected