(self, other=None)
| 416 | return x |
| 417 | |
| 418 | def kl(self, other=None): |
| 419 | if self.deterministic: |
| 420 | return torch.Tensor([0.0]) |
| 421 | else: |
| 422 | if other is None: |
| 423 | return 0.5 * torch.sum( |
| 424 | torch.pow(self.mean, 2) + self.var - 1.0 - self.logvar, |
| 425 | dim=[1, 2, 3], |
| 426 | ) |
| 427 | else: |
| 428 | return 0.5 * torch.sum( |
| 429 | torch.pow(self.mean - other.mean, 2) / other.var |
| 430 | + self.var / other.var |
| 431 | - 1.0 |
| 432 | - self.logvar |
| 433 | + other.logvar, |
| 434 | dim=[1, 2, 3], |
| 435 | ) |
| 436 | |
| 437 | def nll(self, sample, dims=[1, 2, 3]): |
| 438 | if self.deterministic: |
nothing calls this directly
no outgoing calls
no test coverage detected