zoo/senet/se_resnext_c.py
def squeeze_excite_block(self, x, **metaparameters):
        """ Construct a Squeeze and Excite block
            x     : input to the block
            ratio : amount of filter reduction during squeeze
        """  
        ratio = metaparameters['ratio']
            
        # Remember the input
        shortcut = x
    
        # Get the number of filters on the input
        filters = x.shape[-1]

        # Squeeze (dimensionality reduction)
        # Do global average pooling across the filters, which will output a 1D vector
        x = GlobalAveragePooling2D()(x)
    
        # Reshape into 1x1 feature maps (1x1xC)
        x = Reshape((1, 1, filters))(x)
    
        # Reduce the number of filters (1x1xC/r)
        x = self.Dense(x, filters // ratio, activation='relu', use_bias=False, **metaparameters)

        # Excitation (dimensionality restoration)
        # Restore the number of filters (1x1xC)
        x = self.Dense(x, filters, activation='sigmoid', use_bias=False, **metaparameters)

        # Scale - multiply the squeeze/excitation output with the input (WxHxC)
        x = Multiply()([shortcut, x])
        return x
 Construct a Squeeze and Excite block
            x     : input to the block
            ratio : amount of filter reduction during squeeze
        
Construct a Squeeze and Excite block
x     : input to the block
ratio : amount of filter reduction during squeeze
Construct a Squeeze and Excite block x : input to the block ratio : amount of filter reduction during squeeze
def squeeze_excite_block(self, x, **metaparameters):
        ratio = metaparameters['ratio']
        shortcut = x
        filters = x.shape[-1]
        x = GlobalAveragePooling2D()(x)
        x = Reshape((1, 1, filters))(x)
        x = self.Dense(x, filters // ratio, activation='relu', use_bias=False, **metaparameters)
        x = self.Dense(x, filters, activation='sigmoid', use_bias=False, **metaparameters)
        x = Multiply()([shortcut, x])
        return x
def squeeze_excite_block ( self , x , ** metaparameters ) : ratio = metaparameters [ 'ratio' ] shortcut = x filters = x . shape [ - 1 ] x = GlobalAveragePooling2D ( ) ( x ) x = Reshape ( ( 1 , 1 , filters ) ) ( x ) x = self . Dense ( x , filters // ratio , activation = 'relu' , use_bias = False , ** metaparameters ) x = self . Dense ( x , filters , activation = 'sigmoid' , use_bias = False , ** metaparameters ) x = Multiply ( ) ( [ shortcut , x ] ) return x
Construct a Squeeze and Excite block
x     : input to the block
ratio : amount of filter reduction during squeeze
Construct a Squeeze and Excite block x : input to the block ratio : amount of filter reduction during squeeze
""" Construct a Squeeze and Excite block
            x     : input to the block
            ratio : amount of filter reduction during squeeze
        """ # Remember the input # Get the number of filters on the input # Squeeze (dimensionality reduction) # Do global average pooling across the filters, which will output a 1D vector # Reshape into 1x1 feature maps (1x1xC) # Reduce the number of filters (1x1xC/r) # Excitation (dimensionality restoration) # Restore the number of filters (1x1xC) # Scale - multiply the squeeze/excitation output with the input (WxHxC)
self
x