def __init__(self):
        super(_netD, self).__init__()
        ndf = 64
        self.main = nn.Sequential(
            # state size. 1 x 32 x 32
            SNConv2d(1, ndf, 3, 1, 1, bias=True),
            nn.LeakyReLU(0.1, inplace=True),
            SNConv2d(ndf, ndf, 4, 2, 1, bias=True),
            nn.LeakyReLU(0.1, inplace=True),
            # state size. (ndf) x 16 x 16
            SNConv2d(ndf, ndf * 2, 3, 1, 1, bias=True),
            nn.LeakyReLU(0.1, inplace=True),
            SNConv2d(ndf * 2, ndf * 2, 4, 2, 1, bias=True),
            nn.LeakyReLU(0.1, inplace=True),
            # state size. (ndf*2) x 8 x 8
            SNConv2d(ndf * 2, ndf * 4, 3, 1, 1, bias=True),
            nn.LeakyReLU(0.1, inplace=True),
            SNConv2d(ndf * 4, ndf * 4, 4, 2, 1, bias=True),
            nn.LeakyReLU(0.1, inplace=True),
            # state size. (ndf*4) x 4 x 4
            SNConv2d(ndf * 4, ndf * 8, 3, 1, 1, bias=True),
            nn.LeakyReLU(0.1, inplace=True),
        )

        self.ln = nn.Sequential(SNLinear(ndf * 8 * 2 * 5, 1024),
                                nn.LeakyReLU(0.2, inplace=True),
                                SNLinear(1024, 1), nn.Sigmoid())
 def __init__(self):
     super(_netD, self).__init__()
     nc = 1
     ndf = 64
     self.ini_w = 2
     self.ini_h = 5
     self.main = nn.Sequential(
         # input is (nc) x 32 x 32
         SNConv2d(nc, ndf, 3, 1, 1, bias=True),
         nn.LeakyReLU(0.1, inplace=True),
         SNConv2d(ndf, ndf, 4, 2, 1, bias=True),
         nn.LeakyReLU(0.1, inplace=True),
         # state size. (ndf) x 16 x 16
         SNConv2d(ndf, ndf * 2, 3, 1, 1, bias=True),
         nn.LeakyReLU(0.1, inplace=True),
         SNConv2d(ndf * 2, ndf * 2, 4, 2, 1, bias=True),
         nn.LeakyReLU(0.1, inplace=True),
         # state size. (ndf*2) x 8 x 8
         SNConv2d(ndf * 2, ndf * 4, 3, 1, 1, bias=True),
         nn.LeakyReLU(0.1, inplace=True),
         SNConv2d(ndf * 4, ndf * 4, 4, 2, 1, bias=True),
         nn.LeakyReLU(0.1, inplace=True),
         # state size. (ndf*4) x 4 x 4
         SNConv2d(ndf * 4, ndf * 8, 3, 1, 1, bias=True),
         nn.LeakyReLU(0.1, inplace=True),
     )
     self.snlinear = nn.Sequential(
         SNLinear(ndf * 8 * self.ini_w * self.ini_h, 1), nn.Sigmoid())
示例#3
0
 def __init__(self, ndf=64, ndlayers=4):
     super(SNResDiscriminator, self).__init__()
     self.res_d = self.make_model(ndf, ndlayers)
     self.fc = nn.Sequential(SNLinear(ndf * 16, 1), nn.Sigmoid())
示例#4
0
 def __init__(self):
     super(discriminator_SN, self).__init__()
     self.CNN = nn.Sequential(
         SNConv1d(in_channels=2,
                  out_channels=16,
                  kernel_size=31,
                  stride=2,
                  padding=207),
         # nn.BatchNorm2d(64),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=16,
                  out_channels=32,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         # nn.BatchNorm2d(64),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=32,
                  out_channels=32,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         # nn.BatchNorm2d(64),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=32,
                  out_channels=64,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         # nn.BatchNorm2d(64),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=64,
                  out_channels=64,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         # nn.BatchNorm2d(64),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=64,
                  out_channels=128,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         # nn.BatchNorm2d(64),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=128,
                  out_channels=128,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         # nn.BatchNorm2d(8),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=128,
                  out_channels=256,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=256,
                  out_channels=256,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=256,
                  out_channels=512,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=512,
                  out_channels=1024,
                  kernel_size=31,
                  stride=2,
                  padding=15),
         nn.LeakyReLU(0.3),
         SNConv1d(in_channels=1024, out_channels=1, kernel_size=1),
         nn.LeakyReLU(0.3))
     self.FC1 = SNLinear(8, 1)
示例#5
0
    def __init__(self):
        super(discriminator_SN_ff, self).__init__()

        self.CNN = nn.Sequential(
            SNConv2d(in_channels=2,
                     out_channels=4,
                     kernel_size=(1, 7),
                     dilation=(1, 1)),
            # nn.BatchNorm2d(64),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=4,
                     out_channels=8,
                     kernel_size=(7, 1),
                     dilation=(1, 1)),
            # nn.BatchNorm2d(64),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=8,
                     out_channels=16,
                     kernel_size=(5, 5),
                     dilation=(1, 1)),
            # nn.BatchNorm2d(64),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=16,
                     out_channels=32,
                     kernel_size=(5, 5),
                     dilation=(3, 3)),
            # nn.BatchNorm2d(64),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=32,
                     out_channels=64,
                     kernel_size=(5, 5),
                     dilation=(5, 5)),
            # nn.BatchNorm2d(64),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=64,
                     out_channels=128,
                     kernel_size=(5, 5),
                     dilation=(13, 13)),
            # nn.BatchNorm2d(64),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=128, out_channels=256, kernel_size=(1, 31)),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=256, out_channels=512, kernel_size=(1, 31)),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=512, out_channels=1024, kernel_size=(1, 31)),
            nn.LeakyReLU(0.3),
            SNConv2d(in_channels=1024, out_channels=1, kernel_size=1),
            nn.LeakyReLU(0.3))

        self.FC3 = nn.Sequential(nn.Dropout(0.5, False), SNLinear(7 * 73, 1),
                                 nn.ReLU())
        for name, param in self.FC3.named_parameters():
            if 'bias' in name:
                nn.init.constant_(param, 0)
            elif 'weight' in name:
                nn.init.xavier_normal_(param)

        self.FC4 = nn.Sequential(nn.Dropout(0.5, False), nn.Linear(600, 257))
        for name, param in self.FC4.named_parameters():
            if 'bias' in name:
                nn.init.constant_(param, 0)
            elif 'weight' in name:
                nn.init.xavier_normal_(param)
        for name, param in self.CNN.named_parameters():
            if 'bias' in name:
                nn.init.constant_(param, 0.0)
            elif 'weight' in name:
                nn.init.xavier_normal_(param)