(self, other=None)
| 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: |
nothing calls this directly
no outgoing calls
no test coverage detected