Last active
May 16, 2020 03:36
-
-
Save udithhaputhanthri/7a8a0f8dd82f18e7d825d4fd531df733 to your computer and use it in GitHub Desktop.
Introduction to DCGAN using PyTorch
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
class conv_trans_block(nn.Module): | |
def __init__(self,in_channels,out_channels,kernal_size=4,stride=2,padding=1): | |
super(conv_trans_block,self).__init__() | |
self.block=nn.Sequential( | |
nn.ConvTranspose2d(in_channels,out_channels,kernal_size,stride,padding), | |
nn.BatchNorm2d(out_channels), | |
nn.ReLU()) | |
def forward(self,x): | |
return self.block(x) | |
class conv_block(nn.Module): | |
def __init__(self,in_channels,out_channels,kernal_size=4,stride=2,padding=1): | |
super(conv_block,self).__init__() | |
self.block=nn.Sequential( | |
nn.Conv2d(in_channels,out_channels,kernal_size,stride,padding), | |
nn.BatchNorm2d(out_channels), | |
nn.LeakyReLU(0.2)) | |
def forward(self,x): | |
return self.block(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment