Example #1
0
    def create_generator(self, parameters=None, encoded_parameters=None):
        net = GeneratorNet(
            self.loss_function,
            nn.Sequential(
                nn.ConvTranspose2d(100, self.complexity * 8, 4, 1, 0),
                nn.BatchNorm2d(self.complexity * 8), nn.ReLU(True),
                nn.ConvTranspose2d(self.complexity * 8, self.complexity * 4, 4,
                                   2, 1), nn.BatchNorm2d(self.complexity * 4),
                nn.ReLU(True),
                nn.ConvTranspose2d(self.complexity * 4, self.complexity * 2, 4,
                                   2, 1), nn.BatchNorm2d(self.complexity * 2),
                nn.ReLU(True),
                nn.ConvTranspose2d(self.complexity * 2, self.complexity, 4, 2,
                                   1), nn.BatchNorm2d(self.complexity),
                nn.ReLU(True), nn.ConvTranspose2d(self.complexity, 3, 4, 2, 1),
                nn.Tanh()), 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
Example #2
0
    def create_generator(self, parameters=None, encoded_parameters=None):
        net = GeneratorNet(
            self.loss_function,
            Sequential(nn.Linear(self.gen_input_size, 128), nn.Tanh(),
                       nn.Linear(128, 128), nn.Tanh(),
                       nn.Linear(128, self.input_data_size)),
            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
Example #3
0
    def create_generator(self, parameters=None, encoded_parameters=None):
        net = GeneratorNet(
            self.loss_function,
            Sequential(nn.Linear(64, 256), nn.LeakyReLU(0.2),
                       nn.Linear(256, 256), nn.LeakyReLU(0.2),
                       nn.Linear(256, self.input_data_size), nn.Tanh()),
            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
Example #4
0
    def create_generator(self, parameters=None, encoded_parameters=None):
        net = GeneratorNet(
            self.loss_function,
            nn.Sequential(
                nn.ConvTranspose3d(self.z_size,
                                   self.cube_len * 8,
                                   kernel_size=4,
                                   stride=2,
                                   bias=self.bias,
                                   padding=self.pad),
                nn.BatchNorm3d(self.cube_len * 8), nn.ReLU(),
                nn.ConvTranspose3d(self.cube_len * 8,
                                   self.cube_len * 4,
                                   kernel_size=4,
                                   stride=2,
                                   bias=self.bias,
                                   padding=(1, 1, 1)),
                nn.BatchNorm3d(self.cube_len * 4), nn.ReLU(),
                nn.ConvTranspose3d(self.cube_len * 4,
                                   self.cube_len * 2,
                                   kernel_size=4,
                                   stride=2,
                                   bias=self.bias,
                                   padding=(1, 1, 1)),
                nn.BatchNorm3d(self.cube_len * 2), nn.ReLU(),
                nn.ConvTranspose3d(self.cube_len * 2,
                                   self.cube_len,
                                   kernel_size=4,
                                   stride=2,
                                   bias=self.bias,
                                   padding=(1, 1, 1)),
                nn.BatchNorm3d(self.cube_len), nn.ReLU(),
                nn.ConvTranspose3d(self.cube_len,
                                   1,
                                   kernel_size=4,
                                   stride=2,
                                   bias=self.bias,
                                   padding=(1, 1, 1)), 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