Samples from the latent space and return the corresponding image space map. :param num_samples: (Int) Number of samples :param current_device: (Int) Device to run the model :return: (Tensor)
(self,
num_samples:int,
current_device: int, **kwargs)
| 160 | return {'loss': loss, 'Reconstruction_Loss':log_p_x_z.mean(), 'KLD':-kld_loss.mean()} |
| 161 | |
| 162 | def sample(self, |
| 163 | num_samples:int, |
| 164 | current_device: int, **kwargs) -> Tensor: |
| 165 | """ |
| 166 | Samples from the latent space and return the corresponding |
| 167 | image space map. |
| 168 | :param num_samples: (Int) Number of samples |
| 169 | :param current_device: (Int) Device to run the model |
| 170 | :return: (Tensor) |
| 171 | """ |
| 172 | z = torch.randn(num_samples, 1, |
| 173 | self.latent_dim) |
| 174 | |
| 175 | z = z.to(current_device) |
| 176 | |
| 177 | samples = self.decode(z).squeeze() |
| 178 | return samples |
| 179 | |
| 180 | def generate(self, x: Tensor, **kwargs) -> Tensor: |
| 181 | """ |