models/dense_net.py
def transition_layer_to_classes(self, _input, block, layer):
        """
        Adds the transition layer after the last block. This layer outputs the
        estimated probabilities by classes.

        It performs:
        - batch normalisation,
        - ReLU activation function,
        - wider-than-normal average pooling,
        - reshaping the output into a 1d tensor,
        - fully-connected layer (matrix multiplication, weights and biases).

        Args:
            _input: tensor, the operation's input;
            block: `int`, identifier number for the last block;
            layer: `int`, identifier number for the last layer in that block.
        """
        self.features_total = int(_input.get_shape()[-1])
        var_scope = "Transition_to_FC_block_%d" % block
        FC_name = "FC_block_%d" % block
        if not self.preserve_transition_l:
            var_scope += "_layer_%d" % layer
            FC_name += "_layer_%d" % layer

        with tf.variable_scope(var_scope, reuse=tf.AUTO_REUSE):
            # Batch normalisation.
            self.batch_norm_counter = 0
            output = self.batch_norm(
                _input, scope='BatchNorm_'+str(self.batch_norm_counter))
            # ReLU activation function.
            output = tf.nn.relu(output)
            # Wide average pooling.
            last_pool_kernel = int(output.get_shape()[-2])
            output = self.avg_pool(output, k=last_pool_kernel)
            # Reshaping the output into 1d.
            output = tf.reshape(output, [-1, self.features_total])

        # FC (fully-connected) layer.
        self.FC_W = []
        for i in range(self.features_total):
            self.FC_W.append(self.weight_variable_xavier(
                [self.n_classes], name=FC_name+("_W%d" % i)))
        self.FC_W_counter = self.features_total-1
        self.FC_bias = self.bias_variable(
            [self.n_classes], name=FC_name+"_bias")
        stacked_FC_W = tf.stack(self.FC_W, axis=0)
        logits = tf.matmul(output, stacked_FC_W) + self.FC_bias
        return logits

        Adds the transition layer after the last block. This layer outputs the
        estimated probabilities by classes.

        It performs:
        - batch normalisation,
        - ReLU activation function,
        - wider-than-normal average pooling,
        - reshaping the output into a 1d tensor,
        - fully-connected layer (matrix multiplication, weights and biases).

        Args:
            _input: tensor, the operation's input;
            block: `int`, identifier number for the last block;
            layer: `int`, identifier number for the last layer in that block.
        
Adds the transition layer after the last block. This layer outputs the
estimated probabilities by classes.

It performs:
batch normalisation,
ReLU activation function,
wider-than-normal average pooling,
reshaping the output into a 1d tensor,
fully-connected layer (matrix multiplication, weights and biases).
Adds the transition layer after the last block . This layer outputs the estimated probabilities by classes . It performs : batch normalisation ReLU activation function wider - than - normal average pooling reshaping the output into a 1d tensor fully - connected layer ( matrix multiplication weights and biases ) .
def transition_layer_to_classes(self, _input, block, layer):
        self.features_total = int(_input.get_shape()[-1])
        var_scope = "Transition_to_FC_block_%d" % block
        FC_name = "FC_block_%d" % block
        if not self.preserve_transition_l:
            var_scope += "_layer_%d" % layer
            FC_name += "_layer_%d" % layer
        with tf.variable_scope(var_scope, reuse=tf.AUTO_REUSE):
            self.batch_norm_counter = 0
            output = self.batch_norm(
                _input, scope='BatchNorm_'+str(self.batch_norm_counter))
            output = tf.nn.relu(output)
            last_pool_kernel = int(output.get_shape()[-2])
            output = self.avg_pool(output, k=last_pool_kernel)
            output = tf.reshape(output, [-1, self.features_total])
        self.FC_W = []
        for i in range(self.features_total):
            self.FC_W.append(self.weight_variable_xavier(
                [self.n_classes], name=FC_name+("_W%d" % i)))
        self.FC_W_counter = self.features_total-1
        self.FC_bias = self.bias_variable(
            [self.n_classes], name=FC_name+"_bias")
        stacked_FC_W = tf.stack(self.FC_W, axis=0)
        logits = tf.matmul(output, stacked_FC_W) + self.FC_bias
        return logits
def transition_layer_to_classes ( self , _input , block , layer ) : self . features_total = int ( _input . get_shape ( ) [ - 1 ] ) var_scope = "Transition_to_FC_block_%d" % block FC_name = "FC_block_%d" % block if not self . preserve_transition_l : var_scope += "_layer_%d" % layer FC_name += "_layer_%d" % layer with tf . variable_scope ( var_scope , reuse = tf . AUTO_REUSE ) : self . batch_norm_counter = 0 output = self . batch_norm ( _input , scope = 'BatchNorm_' + str ( self . batch_norm_counter ) ) output = tf . nn . relu ( output ) last_pool_kernel = int ( output . get_shape ( ) [ - 2 ] ) output = self . avg_pool ( output , k = last_pool_kernel ) output = tf . reshape ( output , [ - 1 , self . features_total ] ) self . FC_W = [ ] for i in range ( self . features_total ) : self . FC_W . append ( self . weight_variable_xavier ( [ self . n_classes ] , name = FC_name + ( "_W%d" % i ) ) ) self . FC_W_counter = self . features_total - 1 self . FC_bias = self . bias_variable ( [ self . n_classes ] , name = FC_name + "_bias" ) stacked_FC_W = tf . stack ( self . FC_W , axis = 0 ) logits = tf . matmul ( output , stacked_FC_W ) + self . FC_bias return logits
Adds the transition layer after the last block.
Adds the transition layer after the last block .
"""
        Adds the transition layer after the last block. This layer outputs the
        estimated probabilities by classes.

        It performs:
        - batch normalisation,
        - ReLU activation function,
        - wider-than-normal average pooling,
        - reshaping the output into a 1d tensor,
        - fully-connected layer (matrix multiplication, weights and biases).

        Args:
            _input: tensor, the operation's input;
            block: `int`, identifier number for the last block;
            layer: `int`, identifier number for the last layer in that block.
        """ # Batch normalisation. # ReLU activation function. # Wide average pooling. # Reshaping the output into 1d. # FC (fully-connected) layer.
self
_input
tensor, the operation's input.
tensor the operation ' s input .
block
`int`, identifier number for the last block.
` int ` identifier number for the last block .
layer
`int`, identifier number for the last layer in that block.
` int ` identifier number for the last layer in that block .