(im_size, n_chan, n_noise, n_feature, n_extra_layers,
                        batch_norm, finact)
return layers
Create DC-GAN generator network

    Arguments:
        im_size (int): Image size
        n_chan (int): Number of color channels
        n_noise (int): Dimension of noise
        n_feature (int): Base number of features
        n_extra_layers (int): Number of extra convolution layers
        batch_norm(bool): Enable batch normalization
        finact (object): Final activation function
Create DC-GAN generator network
Create DC - GAN generator network
def create_dc_generator(im_size, n_chan, n_noise, n_feature, n_extra_layers,
                        batch_norm, finact):
    """
    Create DC-GAN generator network

    Arguments:
        im_size (int): Image size
        n_chan (int): Number of color channels
        n_noise (int): Dimension of noise
        n_feature (int): Base number of features
        n_extra_layers (int): Number of extra convolution layers
        batch_norm(bool): Enable batch normalization
        finact (object): Final activation function
    """
    assert im_size % 16 == 0, "im_size has to be a multiple of 16"

    _nf = n_feature // 2
    _is = 4  # image size and number of features
    while _is != im_size:
        _nf *= 2
        _is *= 2

    layers = []
    lname = 'gen.initial.{0}-{1}'.format(n_noise, _nf)
    layers.append(deconv_layer(lname, _nf, strides=1, padding=0, batch_norm=batch_norm))
    _is, _nf = 4, _nf
    while _is < im_size//2:
        lname = 'gen.pyramid.{0}-{1}'.format(_nf, _nf//2)
        layers.append(deconv_layer(lname, _nf//2, batch_norm=batch_norm))
        _nf, _is = _nf//2, _is*2  # decrease image size and increase number of features
    for _t in range(n_extra_layers):
        lname = 'gen.extra-layer-{0}.{1}'.format(_t, _nf)
        layers.append(conv_layer(lname, _nf, ker_size=3, strides=1, batch_norm=batch_norm))
    lname = 'gen.final.{0}-{1}'.format(_nf, n_chan)

    layers.append(deconv_layer(lname, n_chan, activation=finact, batch_norm=False))
    return layers
def create_dc_generator ( im_size , n_chan , n_noise , n_feature , n_extra_layers , batch_norm , finact ) : assert im_size % 16 == 0 , "im_size has to be a multiple of 16" _nf = n_feature // 2 _is = 4 # image size and number of features while _is != im_size : _nf *= 2 _is *= 2 layers = [ ] lname = 'gen.initial.{0}-{1}' . format ( n_noise , _nf ) layers . append ( deconv_layer ( lname , _nf , strides = 1 , padding = 0 , batch_norm = batch_norm ) ) _is , _nf = 4 , _nf while _is < im_size // 2 : lname = 'gen.pyramid.{0}-{1}' . format ( _nf , _nf // 2 ) layers . append ( deconv_layer ( lname , _nf // 2 , batch_norm = batch_norm ) ) _nf , _is = _nf // 2 , _is * 2 # decrease image size and increase number of features for _t in range ( n_extra_layers ) : lname = 'gen.extra-layer-{0}.{1}' . format ( _t , _nf ) layers . append ( conv_layer ( lname , _nf , ker_size = 3 , strides = 1 , batch_norm = batch_norm ) ) lname = 'gen.final.{0}-{1}' . format ( _nf , n_chan ) layers . append ( deconv_layer ( lname , n_chan , activation = finact , batch_norm = False ) ) return layers