| 404 | |
| 405 | class Discriminator(nn.Module): |
| 406 | def __init__(self, ngpu): |
| 407 | super(Discriminator, self).__init__() |
| 408 | self.ngpu = ngpu |
| 409 | self.main = nn.Sequential( |
| 410 | # input is ``(nc) x 64 x 64`` |
| 411 | nn.Conv2d(nc, ndf, 4, 2, 1, bias=False), |
| 412 | nn.LeakyReLU(0.2, inplace=True), |
| 413 | # state size. ``(ndf) x 32 x 32`` |
| 414 | nn.Conv2d(ndf, ndf * 2, 4, 2, 1, bias=False), |
| 415 | nn.BatchNorm2d(ndf * 2), |
| 416 | nn.LeakyReLU(0.2, inplace=True), |
| 417 | # state size. ``(ndf*2) x 16 x 16`` |
| 418 | nn.Conv2d(ndf * 2, ndf * 4, 4, 2, 1, bias=False), |
| 419 | nn.BatchNorm2d(ndf * 4), |
| 420 | nn.LeakyReLU(0.2, inplace=True), |
| 421 | # state size. ``(ndf*4) x 8 x 8`` |
| 422 | nn.Conv2d(ndf * 4, ndf * 8, 4, 2, 1, bias=False), |
| 423 | nn.BatchNorm2d(ndf * 8), |
| 424 | nn.LeakyReLU(0.2, inplace=True), |
| 425 | # state size. ``(ndf*8) x 4 x 4`` |
| 426 | nn.Conv2d(ndf * 8, 1, 4, 1, 0, bias=False), |
| 427 | nn.Sigmoid() |
| 428 | ) |
| 429 | |
| 430 | def forward(self, input): |
| 431 | return self.main(input) |