Skip to content

Instantly share code, notes, and snippets.

@bh1995
Created June 30, 2020 09:58
Show Gist options
  • Save bh1995/1ec28a04f6ad4e5b1bf88ceca389f504 to your computer and use it in GitHub Desktop.
Save bh1995/1ec28a04f6ad4e5b1bf88ceca389f504 to your computer and use it in GitHub Desktop.
nc=3
ndf=64
class Discriminator(nn.Module):
def __init__(self):
super(Discriminator, self).__init__()
self.main = nn.Sequential(
# input is (nc) x 128 x 128
nn.Conv2d(nc,ndf,4,2,1, bias=False),
nn.LeakyReLU(0.2, inplace=True),
# state size. (ndf) x 64 x 64
nn.Conv2d(ndf,ndf*2,4,2,1, bias=False),
nn.InstanceNorm2d(ndf * 2),
nn.LeakyReLU(0.2, inplace=True),
# state size. (ndf*2) x 32 x 32
nn.Conv2d(ndf*2, ndf * 4, 4, 2, 1, bias=False),
nn.InstanceNorm2d(ndf * 4),
nn.LeakyReLU(0.2, inplace=True),
# state size. (ndf*4) x 16 x 16
nn.Conv2d(ndf*4,ndf*8,4,1,1),
nn.InstanceNorm2d(ndf*8),
nn.LeakyReLU(0.2, inplace=True),
# state size. (ndf*8) x 15 x 15
nn.Conv2d(ndf*8,1,4,1,1)
# state size. 1 x 14 x 14
)
def forward(self, input):
return self.main(input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment