Last active
February 27, 2020 16:06
-
-
Save harsh-99/2c0eddf78cc2bdcb016a9bbc05e55fc4 to your computer and use it in GitHub Desktop.
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 Discriminator(nn.Module): | |
def __init__(self, image_size, hidden_size): | |
super(Discriminator, self).__init__() | |
# Instead of linear layer one can also use 2d convolution. | |
#Imapge_size -> 784 for MNIST, hidden size is hyperparameter | |
self.fc1 = nn.Linear(image_size, hidden_size) | |
self.relu = nn.LeakyReLU(0.2) #this is the negative slope. | |
self.fc2 = nn.Linear(hidden_size, hidden_size) | |
#the final output is of shape 1, to classify real or fake | |
self.fc3 = nn.Linear(hidden_size, 1) | |
self.sigmoid = nn.Sigmoid() | |
def forward(self, x): | |
out_fc1 = self.fc1(x) | |
out_relu = self.relu(out_fc1) | |
out_fc2 = self.fc2(out_relu) | |
out_relu2 = self.relu(out_fc2) | |
out_fc3 = self.fc3(out_relu2) | |
out = self.sigmoid(out_fc3) | |
return (out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment