/GANArchitecture.py Secret
Created
June 21, 2021 08:27
Star
You must be signed in to star a gist
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
""" | |
Network Architectures | |
The following are the discriminator and generator architectures | |
""" | |
class discriminator(nn.Module): | |
def __init__(self): | |
super(discriminator, self).__init__() | |
self.fc1 = nn.Linear(784, 512) | |
self.fc2 = nn.Linear(512, 1) | |
self.activation = nn.LeakyReLU(0.1) | |
def forward(self, x): | |
x = x.view(-1, 784) | |
x = self.activation(self.fc1(x)) | |
x = self.fc2(x) | |
return nn.Sigmoid()(x) | |
class generator(nn.Module): | |
def __init__(self): | |
super(generator, self).__init__() | |
self.fc1 = nn.Linear(128, 1024) | |
self.fc2 = nn.Linear(1024, 2048) | |
self.fc3 = nn.Linear(2048, 784) | |
self.activation = nn.ReLU() | |
def forward(self, x): | |
x = self.activation(self.fc1(x)) | |
x = self.activation(self.fc2(x)) | |
x = self.fc3(x) | |
x = x.view(-1, 1, 28, 28) | |
return nn.Tanh()(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment