MCPcopy Create free account
hub / github.com/CompVis/diff2flow / __init__

Method __init__

diff2flow/kl_autoencoder.py:46–54  ·  view source on GitHub ↗
(self, parameters, deterministic=False)

Source from the content-addressed store, hash-verified

44
45class DiagonalGaussianDistribution:
46 def __init__(self, parameters, deterministic=False):
47 self.parameters = parameters
48 self.mean, self.logvar = torch.chunk(parameters, 2, dim=1)
49 self.logvar = torch.clamp(self.logvar, -30.0, 20.0)
50 self.deterministic = deterministic
51 self.std = torch.exp(0.5 * self.logvar)
52 self.var = torch.exp(self.logvar)
53 if self.deterministic:
54 self.var = self.std = torch.zeros_like(self.mean).to(device=self.parameters.device)
55
56 def sample(self):
57 x = self.mean + self.std * torch.randn(self.mean.shape).to(device=self.parameters.device)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected