示例#1
0
    def build(self, input_shape):

        #constant layer
        self.const_4_4 = self.add_weight(
            name='4x4/Const/const',
            shape=(1, 512, 4, 4),
            initializer=tf.random_normal_initializer(0, 1),
            trainable=True)
        #early layer 4x4
        self.layer_4_4 = SynthesisMainLayer(fmaps=nf(1),
                                            impl=self.impl,
                                            gpu=self.gpu,
                                            name='4x4')
        self.torgb_4_4 = ToRgbLayer(impl=self.impl, gpu=self.gpu, name='4x4')
        #main layers
        for res in range(3, self.resolution_log2 + 1):
            res_str = str(2**res)
            setattr(
                self, 'layer_{}_{}_up'.format(res_str, res_str),
                SynthesisMainLayer(fmaps=nf(res - 1),
                                   impl=self.impl,
                                   gpu=self.gpu,
                                   up=True,
                                   name='{}x{}'.format(res_str, res_str)))
            setattr(
                self, 'layer_{}_{}'.format(res_str, res_str),
                SynthesisMainLayer(fmaps=nf(res - 1),
                                   impl=self.impl,
                                   gpu=self.gpu,
                                   name='{}x{}'.format(res_str, res_str)))
            setattr(
                self, 'torgb_{}_{}'.format(res_str, res_str),
                ToRgbLayer(impl=self.impl,
                           gpu=self.gpu,
                           name='{}x{}'.format(res_str, res_str)))
示例#2
0
    def build(self, input_shape):

        self.conv2d_0 = Conv2DLayer(fmaps=nf(self.res - 1),
                                    kernel=3,
                                    impl=self.impl,
                                    gpu=self.gpu,
                                    name='Conv0')

        self.bias_0 = self.add_weight(name='Conv0/bias',
                                      shape=(nf(self.res - 1), ),
                                      initializer=tf.random_normal_initializer(
                                          0, 1),
                                      trainable=True)

        self.conv2d_1_down = Conv2DLayer(fmaps=nf(self.res - 2),
                                         kernel=3,
                                         down=True,
                                         resample_kernel=self.resample_kernel,
                                         impl=self.impl,
                                         gpu=self.gpu,
                                         name='Conv1_down')

        self.bias_1_down = self.add_weight(
            name='Conv1_down/bias',
            shape=(nf(self.res - 2), ),
            initializer=tf.random_normal_initializer(0, 1),
            trainable=True)

        self.conv2d_skip = Conv2DLayer(fmaps=nf(self.res - 2),
                                       kernel=1,
                                       down=True,
                                       resample_kernel=self.resample_kernel,
                                       impl=self.impl,
                                       gpu=self.gpu,
                                       name='Skip')
示例#3
0
 def build(self, input_shape):
     
     self.mini_btch_std_layer = MinibatchStdLayer()
     self.from_rgb = FromRgbLayer(fmaps=nf(self.resolution_log2-1), 
                                  name='{}x{}'.format(self.resolution, self.resolution),
                                  impl=self.impl, gpu=self.gpu)
     
     for res in range(self.resolution_log2, 2, -1):
         res_str = str(2**res)
         setattr(self, 'block_{}_{}'.format(res_str, res_str), 
                 BlockLayer(res=res, name='{}x{}'.format(res_str, res_str), 
                            impl=self.impl, gpu=self.gpu))
     
     #last layers
     self.conv_4_4 = Conv2DLayer(fmaps=nf(1), kernel=3, impl=self.impl, 
                                 gpu=self.gpu, name='4x4/Conv')
     self.conv_4_4_bias = self.add_weight(name='4x4/Conv/bias', shape=(512,),
                                          initializer=tf.random_normal_initializer(0,1), trainable=True)
     self.dense_4_4 = DenseLayer(fmaps=512, name='4x4/Dense0')
     self.dense_output = DenseLayer(fmaps=1, name='Output')