Skip to content

Instantly share code, notes, and snippets.

@AshNguyen
Created May 9, 2020 10:40
Show Gist options
  • Save AshNguyen/2e4f43bad14bc3a749e1f06861143c0a to your computer and use it in GitHub Desktop.
Save AshNguyen/2e4f43bad14bc3a749e1f06861143c0a to your computer and use it in GitHub Desktop.
Simple AE in pytorch
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