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)
| 147 | return {'loss': loss, 'Reconstruction_Loss':recons_loss, 'KLD':-kld_loss} |
| 148 | |
| 149 | def sample(self, |
| 150 | num_samples:int, |
| 151 | current_device: int, |
| 152 | **kwargs) -> Tensor: |
| 153 | """ |
| 154 | Samples from the latent space and return the corresponding |
| 155 | image space map. |
| 156 | :param num_samples: (Int) Number of samples |
| 157 | :param current_device: (Int) Device to run the model |
| 158 | :return: (Tensor) |
| 159 | """ |
| 160 | y = kwargs['labels'].float() |
| 161 | z = torch.randn(num_samples, |
| 162 | self.latent_dim) |
| 163 | |
| 164 | z = z.to(current_device) |
| 165 | |
| 166 | z = torch.cat([z, y], dim=1) |
| 167 | samples = self.decode(z) |
| 168 | return samples |
| 169 | |
| 170 | def generate(self, x: Tensor, **kwargs) -> Tensor: |
| 171 | """ |