zoo/siamese_twin/siamese_twin_c.py
def twin(self, input_shape):
        ''' Construct the model for both twins of the Siamese (connected) Network
            input_shape : input shape for input vector
        '''
    
        def stem(inputs):
            ''' Construct the Stem Group
                inputs: the input tensor
            '''

            # entry convolutional layer and reduce feature maps by 75% (max pooling)
            x = self.Conv2D(inputs, 64, (10, 10), activation='relu', kernel_initializer=conv_weights, bias_initializer=biases)
            x = MaxPooling2D((2, 2), strides=2)(x)
            return x
        
        def learner(x):
            ''' Construct the learner 
                x   : input to the learner
            '''
    
            # 2nd convolutional layer doubling the number of filters, and reduce feature maps by 75% (max pooling)
            x = self.Conv2D(x, 128, (7, 7), activation='relu', kernel_initializer=conv_weights, bias_initializer=biases)
            x = MaxPooling2D((2, 2), strides=2)(x)
    
            # 3rd convolutional layer and reduce feature maps by 75% (max pooling)
            x = self.Conv2D(x, 128, (4, 4), activation='relu', kernel_initializer=conv_weights, bias_initializer=biases)
            x = MaxPooling2D((2, 2), strides=2)(x)
        
            # 4th convolutional layer doubling the number of filters with no feature map downsampling
            x = self.Conv2D(x, 256, (4, 4), activation='relu', kernel_initializer=conv_weights, bias_initializer=biases)

            # for a 105x105 input, the feature map size will be 6x6
            return x
        
        def classifier(x):
            ''' Construct the classifier (Encoding block) 
                x  : input to the classifier
            '''

            # flatten the maps into a 1D vector
            x = Flatten()(x)
    
            # use dense layer to produce a 4096 encoding of the flattened feature maps
            x = self.Dense(x, 4096, activation='sigmoid', kernel_initializer=dense_weights, bias_initializer=biases)
            return x

        inputs = Input(shape=input_shape)
        x = stem(inputs)
        x = learner(x)
        outputs = classifier(x)

        return Model(inputs, outputs)
 Construct the model for both twins of the Siamese (connected) Network
            input_shape : input shape for input vector
        
Construct the model for both twins of the Siamese (connected) Network
input_shape : input shape for input vector
Construct the model for both twins of the Siamese ( connected ) Network input_shape : input shape for input vector
def twin(self, input_shape):
        def stem(inputs):
            x = self.Conv2D(inputs, 64, (10, 10), activation='relu', kernel_initializer=conv_weights, bias_initializer=biases)
            x = MaxPooling2D((2, 2), strides=2)(x)
            return x
        def learner(x):
            x = self.Conv2D(x, 128, (7, 7), activation='relu', kernel_initializer=conv_weights, bias_initializer=biases)
            x = MaxPooling2D((2, 2), strides=2)(x)
            x = self.Conv2D(x, 128, (4, 4), activation='relu', kernel_initializer=conv_weights, bias_initializer=biases)
            x = MaxPooling2D((2, 2), strides=2)(x)
            x = self.Conv2D(x, 256, (4, 4), activation='relu', kernel_initializer=conv_weights, bias_initializer=biases)
            return x
        def classifier(x):
            x = Flatten()(x)
            x = self.Dense(x, 4096, activation='sigmoid', kernel_initializer=dense_weights, bias_initializer=biases)
            return x
        inputs = Input(shape=input_shape)
        x = stem(inputs)
        x = learner(x)
        outputs = classifier(x)
        return Model(inputs, outputs)
def twin ( self , input_shape ) : def stem ( inputs ) : ''' Construct the Stem Group
                inputs: the input tensor
            ''' x = self . Conv2D ( inputs , 64 , ( 10 , 10 ) , activation = 'relu' , kernel_initializer = conv_weights , bias_initializer = biases ) x = MaxPooling2D ( ( 2 , 2 ) , strides = 2 ) ( x ) return x def learner ( x ) : ''' Construct the learner 
                x   : input to the learner
            ''' x = self . Conv2D ( x , 128 , ( 7 , 7 ) , activation = 'relu' , kernel_initializer = conv_weights , bias_initializer = biases ) x = MaxPooling2D ( ( 2 , 2 ) , strides = 2 ) ( x ) x = self . Conv2D ( x , 128 , ( 4 , 4 ) , activation = 'relu' , kernel_initializer = conv_weights , bias_initializer = biases ) x = MaxPooling2D ( ( 2 , 2 ) , strides = 2 ) ( x ) x = self . Conv2D ( x , 256 , ( 4 , 4 ) , activation = 'relu' , kernel_initializer = conv_weights , bias_initializer = biases ) return x def classifier ( x ) : ''' Construct the classifier (Encoding block) 
                x  : input to the classifier
            ''' x = Flatten ( ) ( x ) x = self . Dense ( x , 4096 , activation = 'sigmoid' , kernel_initializer = dense_weights , bias_initializer = biases ) return x inputs = Input ( shape = input_shape ) x = stem ( inputs ) x = learner ( x ) outputs = classifier ( x ) return Model ( inputs , outputs )
Construct the model for both twins of the Siamese (connected) Network
input_shape : input shape for input vector
Construct the model for both twins of the Siamese ( connected ) Network input_shape : input shape for input vector
''' Construct the model for both twins of the Siamese (connected) Network
            input_shape : input shape for input vector
        ''' ''' Construct the Stem Group
                inputs: the input tensor
            ''' # entry convolutional layer and reduce feature maps by 75% (max pooling) ''' Construct the learner 
                x   : input to the learner
            ''' # 2nd convolutional layer doubling the number of filters, and reduce feature maps by 75% (max pooling) # 3rd convolutional layer and reduce feature maps by 75% (max pooling) # 4th convolutional layer doubling the number of filters with no feature map downsampling # for a 105x105 input, the feature map size will be 6x6 ''' Construct the classifier (Encoding block) 
                x  : input to the classifier
            ''' # flatten the maps into a 1D vector # use dense layer to produce a 4096 encoding of the flattened feature maps
self
input_shape