Skip to content

Instantly share code, notes, and snippets.

@udithhaputhanthri
Last active May 16, 2020 03:36
Show Gist options
  • Save udithhaputhanthri/7a8a0f8dd82f18e7d825d4fd531df733 to your computer and use it in GitHub Desktop.
Save udithhaputhanthri/7a8a0f8dd82f18e7d825d4fd531df733 to your computer and use it in GitHub Desktop.
Introduction to DCGAN using PyTorch
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