zoo/dcgan/dcgan_c.py
def discriminator(self, input_shape=(28, 28, 1), optimizer=Adam(0.0002, 0.5)):
        """ Construct the discriminator
            input_shape : the input shape of the images
            optimizer   : the optimizer
        """
        
        def stem(inputs):
            x = self.Conv2D(inputs, 32, (3, 3), strides=2, padding="same")
            x = LeakyReLU(alpha=0.2)(x)
            x = Dropout(0.25)(x)
            return x
        
        def learner(x):
            x = self.Conv2D(x, 64, (3, 3), strides=2, padding="same")
            x = ZeroPadding2D(padding=((0,1),(0,1)))(x)
            x = self.BatchNormalization(x, momentum=0.8)
            x = LeakyReLU(alpha=0.2)(x)
            x = Dropout(0.25)(x)
        
            x = self.Conv2D(x, 128, (3, 3), strides=2, padding="same")
            x = self.BatchNormalization(x, momentum=0.8)
            x = LeakyReLU(alpha=0.2)(x)
            x = Dropout(0.25)(x)
        
            x = self.Conv2D(x, 256, (3, 3), strides=1, padding="same")
            x = self.BatchNormalization(x, momentum=0.8)
            x = LeakyReLU(alpha=0.2)(x)
            x = Dropout(0.25)(x)
            return x
        
        def classifier(x):
            x = Flatten()(x)
            outputs = self.Dense(x, 1, activation='sigmoid')
            return outputs
        
        # Construct the discriminator
        inputs = Input(shape=input_shape)
        x = stem(inputs)
        x = learner(x)
        outputs = classifier(x)
        model = Model(inputs, outputs) 
        
        model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])
        
        # For the combined model we will only train the generator
        model.trainable = False
        return model
 Construct the discriminator
            input_shape : the input shape of the images
            optimizer   : the optimizer
        
Construct the discriminator
input_shape : the input shape of the images
optimizer   : the optimizer
Construct the discriminator input_shape : the input shape of the images optimizer : the optimizer
def discriminator(self, input_shape=(28, 28, 1), optimizer=Adam(0.0002, 0.5)):
        def stem(inputs):
            x = self.Conv2D(inputs, 32, (3, 3), strides=2, padding="same")
            x = LeakyReLU(alpha=0.2)(x)
            x = Dropout(0.25)(x)
            return x
        def learner(x):
            x = self.Conv2D(x, 64, (3, 3), strides=2, padding="same")
            x = ZeroPadding2D(padding=((0,1),(0,1)))(x)
            x = self.BatchNormalization(x, momentum=0.8)
            x = LeakyReLU(alpha=0.2)(x)
            x = Dropout(0.25)(x)
            x = self.Conv2D(x, 128, (3, 3), strides=2, padding="same")
            x = self.BatchNormalization(x, momentum=0.8)
            x = LeakyReLU(alpha=0.2)(x)
            x = Dropout(0.25)(x)
            x = self.Conv2D(x, 256, (3, 3), strides=1, padding="same")
            x = self.BatchNormalization(x, momentum=0.8)
            x = LeakyReLU(alpha=0.2)(x)
            x = Dropout(0.25)(x)
            return x
        def classifier(x):
            x = Flatten()(x)
            outputs = self.Dense(x, 1, activation='sigmoid')
            return outputs
        inputs = Input(shape=input_shape)
        x = stem(inputs)
        x = learner(x)
        outputs = classifier(x)
        model = Model(inputs, outputs) 
        model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])
        model.trainable = False
        return model
def discriminator ( self , input_shape = ( 28 , 28 , 1 ) , optimizer = Adam ( 0.0002 , 0.5 ) ) : def stem ( inputs ) : x = self . Conv2D ( inputs , 32 , ( 3 , 3 ) , strides = 2 , padding = "same" ) x = LeakyReLU ( alpha = 0.2 ) ( x ) x = Dropout ( 0.25 ) ( x ) return x def learner ( x ) : x = self . Conv2D ( x , 64 , ( 3 , 3 ) , strides = 2 , padding = "same" ) x = ZeroPadding2D ( padding = ( ( 0 , 1 ) , ( 0 , 1 ) ) ) ( x ) x = self . BatchNormalization ( x , momentum = 0.8 ) x = LeakyReLU ( alpha = 0.2 ) ( x ) x = Dropout ( 0.25 ) ( x ) x = self . Conv2D ( x , 128 , ( 3 , 3 ) , strides = 2 , padding = "same" ) x = self . BatchNormalization ( x , momentum = 0.8 ) x = LeakyReLU ( alpha = 0.2 ) ( x ) x = Dropout ( 0.25 ) ( x ) x = self . Conv2D ( x , 256 , ( 3 , 3 ) , strides = 1 , padding = "same" ) x = self . BatchNormalization ( x , momentum = 0.8 ) x = LeakyReLU ( alpha = 0.2 ) ( x ) x = Dropout ( 0.25 ) ( x ) return x def classifier ( x ) : x = Flatten ( ) ( x ) outputs = self . Dense ( x , 1 , activation = 'sigmoid' ) return outputs inputs = Input ( shape = input_shape ) x = stem ( inputs ) x = learner ( x ) outputs = classifier ( x ) model = Model ( inputs , outputs ) model . compile ( loss = 'binary_crossentropy' , optimizer = optimizer , metrics = [ 'accuracy' ] ) model . trainable = False return model
Construct the discriminator
input_shape : the input shape of the images
optimizer   : the optimizer
Construct the discriminator input_shape : the input shape of the images optimizer : the optimizer
""" Construct the discriminator
            input_shape : the input shape of the images
            optimizer   : the optimizer
        """ # Construct the discriminator # For the combined model we will only train the generator
self
input_shape
optimizer