GAN/Architectures/models/acgan.py
def build_discriminator(self):
        """Override building of the discriminator."""
        # weight initialization
        init = RandomNormal(stddev=0.02)
        # image input
        in_image = Input(shape=self.in_shape)
        # downsample to 14x14
        fe = Conv2D(32, (3,3), strides=(2,2), padding='same', kernel_initializer=init)(in_image)
        fe = LeakyReLU(alpha=0.2)(fe)
        fe = Dropout(0.5)(fe)
        # normal
        fe = Conv2D(64, (3,3), padding='same', kernel_initializer=init)(fe)
        fe = BatchNormalization()(fe)
        fe = LeakyReLU(alpha=0.2)(fe)
        fe = Dropout(0.5)(fe)
        # downsample to 7x7
        fe = Conv2D(128, (3,3), strides=(2,2), padding='same', kernel_initializer=init)(fe)
        fe = BatchNormalization()(fe)
        fe = LeakyReLU(alpha=0.2)(fe)
        fe = Dropout(0.5)(fe)
        # normal
        fe = Conv2D(256, (3,3), padding='same', kernel_initializer=init)(fe)
        fe = BatchNormalization()(fe)
        fe = LeakyReLU(alpha=0.2)(fe)
        fe = Dropout(0.5)(fe)
        # flatten feature maps
        fe = Flatten()(fe)
        # real/fake output
        out1 = Dense(1, activation='sigmoid')(fe)
        # class label output
        out2 = Dense(self.n_classes, activation='softmax')(fe)
        # define model
        self.d_model = Model(in_image, [out1, out2])
        # compile model
        opt = Adam(lr=0.0002, beta_1=0.5)
        self.d_model.compile(loss=['binary_crossentropy', 'sparse_categorical_crossentropy'], optimizer=opt)
Override building of the discriminator.
Override building of the discriminator.
Override building of the discriminator .
def build_discriminator(self):
        init = RandomNormal(stddev=0.02)
        in_image = Input(shape=self.in_shape)
        fe = Conv2D(32, (3,3), strides=(2,2), padding='same', kernel_initializer=init)(in_image)
        fe = LeakyReLU(alpha=0.2)(fe)
        fe = Dropout(0.5)(fe)
        fe = Conv2D(64, (3,3), padding='same', kernel_initializer=init)(fe)
        fe = BatchNormalization()(fe)
        fe = LeakyReLU(alpha=0.2)(fe)
        fe = Dropout(0.5)(fe)
        fe = Conv2D(128, (3,3), strides=(2,2), padding='same', kernel_initializer=init)(fe)
        fe = BatchNormalization()(fe)
        fe = LeakyReLU(alpha=0.2)(fe)
        fe = Dropout(0.5)(fe)
        fe = Conv2D(256, (3,3), padding='same', kernel_initializer=init)(fe)
        fe = BatchNormalization()(fe)
        fe = LeakyReLU(alpha=0.2)(fe)
        fe = Dropout(0.5)(fe)
        fe = Flatten()(fe)
        out1 = Dense(1, activation='sigmoid')(fe)
        out2 = Dense(self.n_classes, activation='softmax')(fe)
        self.d_model = Model(in_image, [out1, out2])
        opt = Adam(lr=0.0002, beta_1=0.5)
        self.d_model.compile(loss=['binary_crossentropy', 'sparse_categorical_crossentropy'], optimizer=opt)
def build_discriminator ( self ) : init = RandomNormal ( stddev = 0.02 ) in_image = Input ( shape = self . in_shape ) fe = Conv2D ( 32 , ( 3 , 3 ) , strides = ( 2 , 2 ) , padding = 'same' , kernel_initializer = init ) ( in_image ) fe = LeakyReLU ( alpha = 0.2 ) ( fe ) fe = Dropout ( 0.5 ) ( fe ) fe = Conv2D ( 64 , ( 3 , 3 ) , padding = 'same' , kernel_initializer = init ) ( fe ) fe = BatchNormalization ( ) ( fe ) fe = LeakyReLU ( alpha = 0.2 ) ( fe ) fe = Dropout ( 0.5 ) ( fe ) fe = Conv2D ( 128 , ( 3 , 3 ) , strides = ( 2 , 2 ) , padding = 'same' , kernel_initializer = init ) ( fe ) fe = BatchNormalization ( ) ( fe ) fe = LeakyReLU ( alpha = 0.2 ) ( fe ) fe = Dropout ( 0.5 ) ( fe ) fe = Conv2D ( 256 , ( 3 , 3 ) , padding = 'same' , kernel_initializer = init ) ( fe ) fe = BatchNormalization ( ) ( fe ) fe = LeakyReLU ( alpha = 0.2 ) ( fe ) fe = Dropout ( 0.5 ) ( fe ) fe = Flatten ( ) ( fe ) out1 = Dense ( 1 , activation = 'sigmoid' ) ( fe ) out2 = Dense ( self . n_classes , activation = 'softmax' ) ( fe ) self . d_model = Model ( in_image , [ out1 , out2 ] ) opt = Adam ( lr = 0.0002 , beta_1 = 0.5 ) self . d_model . compile ( loss = [ 'binary_crossentropy' , 'sparse_categorical_crossentropy' ] , optimizer = opt )
Override building of the discriminator.
Override building of the discriminator .
"""Override building of the discriminator.""" # weight initialization # image input # downsample to 14x14 # normal # downsample to 7x7 # normal # flatten feature maps # real/fake output # class label output # define model # compile model
self