Discriminator.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Keras-GAN 作者: Shaofanl 项目源码 文件源码
def __init__(self, 
                    d_size=(3, 128, 64),
                    d_nb_filters=128,
                    d_scales=4,
                    d_FC=None,
                    d_init=None,
                **kwargs):
        super(Critic, self).__init__(**kwargs)

        self.d_size = d_size
        self.d_nb_filters = d_nb_filters
        self.d_scales = d_scales
        self.d_FC = d_FC
        self.d_init = d_init if d_init is not None else InitNormal()

        c, h, w = d_size # h and w should be multiply of 16
        nf = d_nb_filters

        for s in range(d_scales):
            if s == 0: 
                self.add( ZeroPadding2D((2, 2), input_shape=d_size) )
            else:
                self.add( ZeroPadding2D((2, 2)) )

            self.add( Convolution2D(nf*(2**s), 5, 5, subsample=(2,2), border_mode='valid',) )
            self.add( BN() )
#           self.add( BatchNormalization(beta_init='zero', gamma_init='one', mode=2, axis=1) )
            self.add( LeakyReLU(0.2) )

        self.add( Flatten() )
        if d_FC is not None:
            for fc_dim in d_FC:
                self.add( Dense(fc_dim,) )
                self.add( LeakyReLU(0.2) )
                self.add( BN() )
#               self.add( BatchNormalization(beta_init='zero', gamma_init='one', mode=2) )
                self.add( LeakyReLU(0.2) )
        self.add( Dense(1, activation='linear',) )
        d_init(self)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号