(self, z: torch.Tensor)
| 96 | yield from () |
| 97 | |
| 98 | def forward(self, z: torch.Tensor) -> Tuple[torch.Tensor, dict]: |
| 99 | log = dict() |
| 100 | posterior = DiagonalGaussianDistribution(z) |
| 101 | if self.sample: |
| 102 | z = posterior.sample() |
| 103 | else: |
| 104 | z = posterior.mode() |
| 105 | kl_loss = posterior.kl() |
| 106 | kl_loss = torch.sum(kl_loss) / kl_loss.shape[0] |
| 107 | log["kl_loss"] = kl_loss |
| 108 | return z, log |
nothing calls this directly
no test coverage detected