Skip to content

Instantly share code, notes, and snippets.

@udithhaputhanthri
Last active May 29, 2020 18:08
Show Gist options
  • Save udithhaputhanthri/ffdff24d68dea70e2a02a73443170e68 to your computer and use it in GitHub Desktop.
Save udithhaputhanthri/ffdff24d68dea70e2a02a73443170e68 to your computer and use it in GitHub Desktop.
Image-to-Image Translation Using Conditional DCGANs
class conv_block(nn.Module):
def __init__(self,in_channels,out_channels,kernel_size=4,stride=2,padding=1):
super(conv_block,self).__init__()
self.conv_block=nn.Sequential(
nn.Conv2d(in_channels,out_channels,kernel_size,stride,padding),
nn.LeakyReLU(0.2),
nn.BatchNorm2d(out_channels)
)
def forward(self,x):
return self.conv_block(x)
class transconv_block(nn.Module):
def __init__(self,in_channels,out_channels,kernel_size=4,stride=2,padding=1):
super(transconv_block,self).__init__()
self.transconv_block=nn.Sequential(
nn.ConvTranspose2d(in_channels,out_channels,kernel_size,stride,padding),
nn.ReLU(),
nn.BatchNorm2d(out_channels)
)
def forward(self,x):
return self.transconv_block(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment