示例#1
0
    def create_discriminator(self, parameters=None, encoded_parameters=None):
        net = DiscriminatorNet(
            self.loss_function,
            Sequential(
                nn.Conv2d(3, self.complexity, 4, 2, 1),
                nn.LeakyReLU(0.2, inplace=True),
                nn.Conv2d(self.complexity, self.complexity * 2, 4, 2, 1),
                nn.BatchNorm2d(self.complexity * 2),
                nn.LeakyReLU(0.2, inplace=True),
                nn.Conv2d(self.complexity * 2, self.complexity * 4, 4, 2, 1),
                nn.BatchNorm2d(self.complexity * 4),
                nn.LeakyReLU(0.2, inplace=True),
                nn.Conv2d(self.complexity * 4, self.complexity * 8, 4, 2, 1),
                nn.BatchNorm2d(self.complexity * 8),
                nn.LeakyReLU(0.2, inplace=True),
                nn.Conv2d(self.complexity * 8, 1, 4, 1, 0), nn.Sigmoid()),
            self.gen_input_size)

        if parameters is not None:
            net.parameters = parameters
        elif encoded_parameters is not None:
            net.encoded_parameters = encoded_parameters
        else:
            net.net.apply(self._init_weights)

        return net
示例#2
0
    def create_discriminator(self, parameters=None, encoded_parameters=None):
        net = DiscriminatorNet(
            self.loss_function,
            Sequential(nn.Linear(self.input_data_size, 128), nn.Tanh(),
                       nn.Linear(128, 128), nn.Tanh(), nn.Linear(128, 1),
                       nn.Sigmoid()), self.gen_input_size)

        if parameters is not None:
            net.parameters = parameters
        if encoded_parameters is not None:
            net.encoded_parameters = encoded_parameters

        return net
示例#3
0
    def create_discriminator(self, parameters=None, encoded_parameters=None):
        net = DiscriminatorNet(
            self.loss_function,
            Sequential(
                nn.Conv3d(1,
                          self.cube_len,
                          kernel_size=4,
                          stride=2,
                          bias=self.bias,
                          padding=(1, 1, 1)), nn.BatchNorm3d(self.cube_len),
                nn.LeakyReLU(self.leak_value),
                nn.Conv3d(self.cube_len,
                          self.cube_len * 2,
                          kernel_size=4,
                          stride=2,
                          bias=self.bias,
                          padding=(1, 1,
                                   1)), nn.BatchNorm3d(self.cube_len * 2),
                nn.LeakyReLU(self.leak_value),
                nn.Conv3d(self.cube_len * 2,
                          self.cube_len * 4,
                          kernel_size=4,
                          stride=2,
                          bias=self.bias,
                          padding=(1, 1,
                                   1)), nn.BatchNorm3d(self.cube_len * 4),
                nn.LeakyReLU(self.leak_value),
                nn.Conv3d(self.cube_len * 4,
                          self.cube_len * 8,
                          kernel_size=4,
                          stride=2,
                          bias=self.bias,
                          padding=(1, 1, 1)),
                nn.BatchNorm3d(self.cube_len * 8),
                nn.LeakyReLU(self.leak_value),
                nn.Conv3d(self.cube_len * 8,
                          1,
                          kernel_size=4,
                          stride=2,
                          bias=self.bias,
                          padding=self.pad), nn.Sigmoid()),
            self.gen_input_size)

        if not (parameters == None):
            net.parameters = parameters
        elif not (encoded_parameters == None):
            net.encoded_parameters = encoded_parameters
        else:
            net.net.apply(self._init_weights)

        return net
示例#4
0
    def create_discriminator(self, parameters=None, encoded_parameters=None):

        net = DiscriminatorNet(
            self.loss_function,
            Sequential(nn.Linear(self.input_data_size, 512), nn.LeakyReLU(0.2),
                       nn.Linear(512, 256), nn.LeakyReLU(0.2),
                       nn.Linear(256, 256), nn.LeakyReLU(0.2),
                       nn.Linear(256, 1), nn.Sigmoid()), self.gen_input_size)

        if parameters is not None:
            net.parameters = parameters
        if encoded_parameters is not None:
            net.encoded_parameters = encoded_parameters

        return net