Created
May 9, 2020 10:40
-
-
Save AshNguyen/2e4f43bad14bc3a749e1f06861143c0a to your computer and use it in GitHub Desktop.
Simple AE in pytorch
This file contains hidden or 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, n_latent): | |
super(AE, self).__init__() | |
self.encoder = nn.Sequential( | |
nn.Linear(28 * 28, 128), | |
nn.ReLU(True), | |
nn.Linear(128, 64), | |
nn.ReLU(True), | |
nn.Linear(64, n_latent)) | |
self.decoder = nn.Sequential( | |
nn.Linear(n_latent, 64), | |
nn.ReLU(True), | |
nn.Linear(64, 128), | |
nn.ReLU(True), | |
nn.Linear(128, 28 * 28), | |
nn.Sigmoid()) | |
def forward(self, x): | |
x = self.encoder(x) | |
x = self.decoder(x) | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment