(self,
*args,
**kwargs)
| 131 | return [self.decode(z), input, mu, log_var] |
| 132 | |
| 133 | def loss_function(self, |
| 134 | *args, |
| 135 | **kwargs) -> dict: |
| 136 | recons = args[0] |
| 137 | input = args[1] |
| 138 | mu = args[2] |
| 139 | log_var = args[3] |
| 140 | |
| 141 | kld_weight = kwargs['M_N'] # Account for the minibatch samples from the dataset |
| 142 | recons_loss =F.mse_loss(recons, input) |
| 143 | |
| 144 | kld_loss = torch.mean(-0.5 * torch.sum(1 + log_var - mu ** 2 - log_var.exp(), dim = 1), dim = 0) |
| 145 | |
| 146 | loss = recons_loss + kld_weight * kld_loss |
| 147 | return {'loss': loss, 'Reconstruction_Loss':recons_loss, 'KLD':-kld_loss} |
| 148 | |
| 149 | def sample(self, |
| 150 | num_samples:int, |
nothing calls this directly
no outgoing calls
no test coverage detected