Last active
July 31, 2020 17:50
-
-
Save IanCarrasco/7d22da400856fa7a81521939b0380947 to your computer and use it in GitHub Desktop.
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
#md | DCGAN Generator | |
#mdi | https://miro.medium.com/max/1400/1*5ALjnfAqwcWbOsledTBXsw.png | |
class generator(nn.Module): | |
# initializers | |
def __init__(self, d=128): | |
super(generator, self).__init__() | |
self.deconv1 = nn.ConvTranspose2d(100, d*8, 4, 1, 0) #md | Deconvolution | sub | |
self.deconv1_bn = nn.BatchNorm2d(d*8) #md | Batch Normalization | sub | |
self.deconv2 = nn.ConvTranspose2d(d*8, d*4, 4, 2, 1) | |
self.deconv2_bn = nn.BatchNorm2d(d*4) | |
self.deconv3 = nn.ConvTranspose2d(d*4, d*2, 4, 2, 1) | |
self.deconv3_bn = nn.BatchNorm2d(d*2) | |
self.deconv4 = nn.ConvTranspose2d(d*2, d, 4, 2, 1) | |
self.deconv4_bn = nn.BatchNorm2d(d) | |
self.deconv5 = nn.ConvTranspose2d(d, 3, 4, 2, 1) | |
#md | Model Benchmarks | |
for m in self._modules: | |
normal_init(self._modules[m], mean, std) | |
# forward method | |
def forward(self, input): | |
# x = F.relu(self.deconv1(input)) | |
x = F.relu(self.deconv1_bn(self.deconv1(input))) | |
x = F.relu(self.deconv2_bn(self.deconv2(x))) | |
x = F.relu(self.deconv3_bn(self.deconv3(x))) | |
x = F.relu(self.deconv4_bn(self.deconv4(x))) | |
x = F.tanh(self.deconv5(x)) | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment