GAN/Architectures/models/acgan.py
def build_generator(self):
        """Override building the standalone generator model"""
        # weight initialization
        init = RandomNormal(stddev=0.02)
        # label input
        in_label = Input(shape=(1,))
        # embedding for categorical input
        li = Embedding(self.n_classes, 50)(in_label)
        # linear multiplication
        n_nodes = 7 * 7
        li = Dense(n_nodes, kernel_initializer=init)(li)
        # reshape to additional channel
        li = Reshape((7, 7, 1))(li)
        # image generator input
        in_lat = Input(shape=(self.latent_dim,))
        # foundation for 7x7 image
        n_nodes = 384 * 7 * 7
        gen = Dense(n_nodes, kernel_initializer=init)(in_lat)
        gen = Activation('relu')(gen)
        gen = Reshape((7, 7, 384))(gen)
        # merge image gen and label input
        merge = Concatenate()([gen, li])
        # upsample to 14x14
        gen = Conv2DTranspose(192, (5,5), strides=(2,2), padding='same', kernel_initializer=init)(merge)
        gen = BatchNormalization()(gen)
        gen = Activation('relu')(gen)
        # upsample to 28x28
        gen = Conv2DTranspose(1, (5,5), strides=(2,2), padding='same', kernel_initializer=init)(gen)
        out_layer = Activation('tanh')(gen)
        # define model
        self.g_model = Model([in_lat, in_label], out_layer)
Override building the standalone generator model
Override building the standalone generator model
Override building the standalone generator model
def build_generator(self):
        init = RandomNormal(stddev=0.02)
        in_label = Input(shape=(1,))
        li = Embedding(self.n_classes, 50)(in_label)
        n_nodes = 7 * 7
        li = Dense(n_nodes, kernel_initializer=init)(li)
        li = Reshape((7, 7, 1))(li)
        in_lat = Input(shape=(self.latent_dim,))
        n_nodes = 384 * 7 * 7
        gen = Dense(n_nodes, kernel_initializer=init)(in_lat)
        gen = Activation('relu')(gen)
        gen = Reshape((7, 7, 384))(gen)
        merge = Concatenate()([gen, li])
        gen = Conv2DTranspose(192, (5,5), strides=(2,2), padding='same', kernel_initializer=init)(merge)
        gen = BatchNormalization()(gen)
        gen = Activation('relu')(gen)
        gen = Conv2DTranspose(1, (5,5), strides=(2,2), padding='same', kernel_initializer=init)(gen)
        out_layer = Activation('tanh')(gen)
        self.g_model = Model([in_lat, in_label], out_layer)
def build_generator ( self ) : init = RandomNormal ( stddev = 0.02 ) in_label = Input ( shape = ( 1 , ) ) li = Embedding ( self . n_classes , 50 ) ( in_label ) n_nodes = 7 * 7 li = Dense ( n_nodes , kernel_initializer = init ) ( li ) li = Reshape ( ( 7 , 7 , 1 ) ) ( li ) in_lat = Input ( shape = ( self . latent_dim , ) ) n_nodes = 384 * 7 * 7 gen = Dense ( n_nodes , kernel_initializer = init ) ( in_lat ) gen = Activation ( 'relu' ) ( gen ) gen = Reshape ( ( 7 , 7 , 384 ) ) ( gen ) merge = Concatenate ( ) ( [ gen , li ] ) gen = Conv2DTranspose ( 192 , ( 5 , 5 ) , strides = ( 2 , 2 ) , padding = 'same' , kernel_initializer = init ) ( merge ) gen = BatchNormalization ( ) ( gen ) gen = Activation ( 'relu' ) ( gen ) gen = Conv2DTranspose ( 1 , ( 5 , 5 ) , strides = ( 2 , 2 ) , padding = 'same' , kernel_initializer = init ) ( gen ) out_layer = Activation ( 'tanh' ) ( gen ) self . g_model = Model ( [ in_lat , in_label ] , out_layer )
Override building the standalone generator model
Override building the standalone generator model
"""Override building the standalone generator model""" # weight initialization # label input # embedding for categorical input # linear multiplication # reshape to additional channel # image generator input # foundation for 7x7 image # merge image gen and label input # upsample to 14x14 # upsample to 28x28 # define model
self