Skip to content

Instantly share code, notes, and snippets.

@AshNguyen
Created May 9, 2020 10:40
Show Gist options
  • Select an option

  • Save AshNguyen/2e4f43bad14bc3a749e1f06861143c0a to your computer and use it in GitHub Desktop.

Select an option

Save AshNguyen/2e4f43bad14bc3a749e1f06861143c0a to your computer and use it in GitHub Desktop.

Revisions

  1. AshNguyen created this gist May 9, 2020.
    21 changes: 21 additions & 0 deletions simple_ae.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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