(self, other=None)
| 58 | return x |
| 59 | |
| 60 | def kl(self, other=None): |
| 61 | if self.deterministic: |
| 62 | return torch.Tensor([0.]) |
| 63 | else: |
| 64 | if other is None: |
| 65 | return 0.5 * torch.sum(torch.pow(self.mean, 2) |
| 66 | + self.var - 1.0 - self.logvar, |
| 67 | dim=[1, 2, 3]) |
| 68 | else: |
| 69 | return 0.5 * torch.sum( |
| 70 | torch.pow(self.mean - other.mean, 2) / other.var |
| 71 | + self.var / other.var - 1.0 - self.logvar + other.logvar, |
| 72 | dim=[1, 2, 3]) |
| 73 | |
| 74 | def nll(self, sample, dims=[1,2,3]): |
| 75 | if self.deterministic: |
nothing calls this directly
no outgoing calls
no test coverage detected