MCPcopy Create free account
hub / github.com/KeepTryingTo/Pytorch-GAN / sample

Method sample

PyTorch-VAE/models/cvae.py:149–168  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.95

Tested by

no test coverage detected