Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. class Discriminator(nn.Module):
  2. def __init__(self, ngpu):
  3. super(Discriminator, self).__init__()
  4. self.ngpu = ngpu
  5. self.main = nn.Sequential(
  6. # input is (nc) x 64 x 64
  7. nn.Conv2d(nc, ndf, 4, 2, 1, bias=False),
  8. nn.LeakyReLU(0.2, inplace=True),
  9. # state size. (ndf) x 32 x 32
  10. nn.Conv2d(ndf, ndf * 2, 4, 2, 1, bias=False),
  11. nn.BatchNorm2d(ndf * 2),
  12. nn.LeakyReLU(0.2, inplace=True),
  13. # state size. (ndf*2) x 16 x 16
  14. nn.Conv2d(ndf * 2, ndf * 4, 4, 2, 1, bias=False),
  15. nn.BatchNorm2d(ndf * 4),
  16. nn.LeakyReLU(0.2, inplace=True),
  17. # state size. (ndf*4) x 8 x 8
  18. nn.Conv2d(ndf * 4, ndf * 8, 4, 2, 1, bias=False),
  19. nn.BatchNorm2d(ndf * 8),
  20. nn.LeakyReLU(0.2, inplace=True),
  21. # state size. (ndf*8) x 4 x 4
  22. nn.Conv2d(ndf * 8, 1, 4, 1, 0, bias=False),
  23. nn.Sigmoid()
  24. )
  25.  
  26. def forward(self, input):
  27. return self.main(input)
  28.  
  29. class Generator(nn.Module):
  30. def __init__(self, ngpu):
  31. super(Generator, self).__init__()
  32. self.ngpu = ngpu
  33. self.main = nn.Sequential(
  34. # input is Z, going into a convolution
  35. nn.ConvTranspose2d( nz, ngf * 8, 4, 1, 0, bias=False),
  36. nn.BatchNorm2d(ngf * 8),
  37. nn.ReLU(True),
  38. # state size. (ngf*8) x 4 x 4
  39. nn.ConvTranspose2d(ngf * 8, ngf * 4, 4, 2, 1, bias=False),
  40. nn.BatchNorm2d(ngf * 4),
  41. nn.ReLU(True),
  42. # state size. (ngf*4) x 8 x 8
  43. nn.ConvTranspose2d( ngf * 4, ngf * 2, 4, 2, 1, bias=False),
  44. nn.BatchNorm2d(ngf * 2),
  45. nn.ReLU(True),
  46. # state size. (ngf*2) x 16 x 16
  47. nn.ConvTranspose2d( ngf * 2, ngf, 4, 2, 1, bias=False),
  48. nn.BatchNorm2d(ngf),
  49. nn.ReLU(True),
  50. # state size. (ngf) x 32 x 32
  51. nn.ConvTranspose2d( ngf, nc, 4, 2, 1, bias=False),
  52. nn.Tanh()
  53. # state size. (nc) x 64 x 64
  54. )
  55.  
  56. def forward(self, input):
  57. return self.main(input)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement