MCPcopy Create free account
hub / github.com/AlayaLab/Hive / __init__

Method __init__

models/flowsep/diffusers/models/vae.py:398–408  ·  view source on GitHub ↗
(self, parameters, deterministic=False)

Source from the content-addressed store, hash-verified

396
397class DiagonalGaussianDistribution(object):
398 def __init__(self, parameters, deterministic=False):
399 self.parameters = parameters
400 self.mean, self.logvar = torch.chunk(parameters, 2, dim=1)
401 self.logvar = torch.clamp(self.logvar, -30.0, 20.0)
402 self.deterministic = deterministic
403 self.std = torch.exp(0.5 * self.logvar)
404 self.var = torch.exp(self.logvar)
405 if self.deterministic:
406 self.var = self.std = torch.zeros_like(
407 self.mean, device=self.parameters.device, dtype=self.parameters.dtype
408 )
409
410 def sample(self, generator: Optional[torch.Generator] = None) -> torch.FloatTensor:
411 # make sure sample is on the same device as the parameters and has same dtype

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected