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

Method encode

PyTorch-VAE/models/fvae.py:92–107  ·  view source on GitHub ↗

Encodes the input by passing through the encoder network and returns the latent codes. :param input: (Tensor) Input tensor to encoder [N x C x H x W] :return: (Tensor) List of latent codes

(self, input: Tensor)

Source from the content-addressed store, hash-verified

90
91
92 def encode(self, input: Tensor) -> List[Tensor]:
93 """
94 Encodes the input by passing through the encoder network
95 and returns the latent codes.
96 :param input: (Tensor) Input tensor to encoder [N x C x H x W]
97 :return: (Tensor) List of latent codes
98 """
99 result = self.encoder(input)
100 result = torch.flatten(result, start_dim=1)
101
102 # Split the result into mu and var components
103 # of the latent Gaussian distribution
104 mu = self.fc_mu(result)
105 log_var = self.fc_var(result)
106
107 return [mu, log_var]
108
109 def decode(self, z: Tensor) -> Tensor:
110 """

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected