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

Method encode

PyTorch-VAE/models/beta_vae.py:88–103  ·  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

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

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected