MCPcopy Create free account
hub / github.com/TencentARC/MotionCtrl / kl

Method kl

lvdm/distributions.py:42–54  ·  view source on GitHub ↗
(self, other=None)

Source from the content-addressed store, hash-verified

40 return x
41
42 def kl(self, other=None):
43 if self.deterministic:
44 return torch.Tensor([0.])
45 else:
46 if other is None:
47 return 0.5 * torch.sum(torch.pow(self.mean, 2)
48 + self.var - 1.0 - self.logvar,
49 dim=[1, 2, 3])
50 else:
51 return 0.5 * torch.sum(
52 torch.pow(self.mean - other.mean, 2) / other.var
53 + self.var / other.var - 1.0 - self.logvar + other.logvar,
54 dim=[1, 2, 3])
55
56 def nll(self, sample, dims=[1,2,3]):
57 if self.deterministic:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected