-
-
Save alierkan/e077cfaf2e89fe7cc0a31bfd7f6f7abc to your computer and use it in GitHub Desktop.
PyTorch implementation of a vanilla autoencoder model.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AE(nn.Module): | |
def __init__(self, **kwargs): | |
super().__init__() | |
self.encoder_hidden_layer = nn.Linear( | |
in_features=kwargs["input_shape"], out_features=128 | |
) | |
self.encoder_output_layer = nn.Linear( | |
in_features=128, out_features=128 | |
) | |
self.decoder_hidden_layer = nn.Linear( | |
in_features=128, out_features=128 | |
) | |
self.decoder_output_layer = nn.Linear( | |
in_features=128, out_features=kwargs["input_shape"] | |
) | |
def forward(self, features): | |
activation = self.encoder_hidden_layer(features) | |
activation = torch.relu(activation) | |
code = self.encoder_output_layer(activation) | |
code = torch.relu(code) | |
activation = self.decoder_hidden_layer(code) | |
activation = torch.relu(activation) | |
activation = self.decoder_output_layer(activation) | |
reconstructed = torch.relu(activation) | |
return reconstructed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment