models/dense_net.py
def self_constructing_var1(self, epoch, accuracy):
        """
        A step of the self-constructing algorithm (variant #1) for one
        training epoch.
        Adds new layers to the last block depending on parameters.
        Returns True if training should continue, False otherwise.

        This algorithm consists in a succession of two stages:
        - Ascension: add one layer every asc_thresh training epochs, break the
          loop (end the stage) when a layer settles (its layer cs for sources
          is == 1).
        - Improvement: end the stage when a total of max_n_ep epochs have
          elapsed (since the addition of the last block);
          if another layer settles, add a layer and restart the countdown.

        Args:
            epoch: `int`, current training epoch (since adding the last block);
            accuracy: `float`, accuracy for this epoch (here unused).
        """
        continue_training = True
        cs, lcs_dst, lcs_src = self.process_block_filters(
            self.total_blocks-1, epoch)

        # calculate number of settled layers (layers with lcs_src == 1)
        settled_layers = 0
        for src in range(1, len(lcs_src)):
            if lcs_src[src] >= 1:
                settled_layers += 1

        # stage #0 = ascension stage
        if self.algorithm_stage == 0:
            if settled_layers > 0:
                self.settled_layers_ceil = settled_layers
                self.algorithm_stage += 1
            elif (epoch-1) % self.asc_thresh == 0:
                self._new_layer(self.growth_rate)

        # stage #1 = improvement stage
        if self.algorithm_stage == 1:
            if epoch >= self.max_n_ep:
                # stop algorithm and reset everything
                continue_training = False
                self.algorithm_stage = 0
            elif settled_layers > self.settled_layers_ceil:
                self.settled_layers_ceil = settled_layers
                self._new_layer(self.growth_rate)

        return continue_training

        A step of the self-constructing algorithm (variant #1) for one
        training epoch.
        Adds new layers to the last block depending on parameters.
        Returns True if training should continue, False otherwise.

        This algorithm consists in a succession of two stages:
        - Ascension: add one layer every asc_thresh training epochs, break the
          loop (end the stage) when a layer settles (its layer cs for sources
          is == 1).
        - Improvement: end the stage when a total of max_n_ep epochs have
          elapsed (since the addition of the last block);
          if another layer settles, add a layer and restart the countdown.

        Args:
            epoch: `int`, current training epoch (since adding the last block);
            accuracy: `float`, accuracy for this epoch (here unused).
        
A step of the self-constructing algorithm (variant #1) for one
training epoch.
Adds new layers to the last block depending on parameters.
Returns True if training should continue, False otherwise.

This algorithm consists in a succession of two stages:
Ascension: add one layer every asc_thresh training epochs, break the
loop (end the stage) when a layer settles (its layer cs for sources
is == 1).
Improvement: end the stage when a total of max_n_ep epochs have
elapsed (since the addition of the last block);
if another layer settles, add a layer and restart the countdown.
A step of the self - constructing algorithm ( variant #1 ) for one training epoch . Adds new layers to the last block depending on parameters . Returns True if training should continue False otherwise . This algorithm consists in a succession of two stages : Ascension : add one layer every asc_thresh training epochs break the loop ( end the stage ) when a layer settles ( its layer cs for sources is == 1 ) . Improvement : end the stage when a total of max_n_ep epochs have elapsed ( since the addition of the last block ) ; if another layer settles add a layer and restart the countdown .
def self_constructing_var1(self, epoch, accuracy):
        continue_training = True
        cs, lcs_dst, lcs_src = self.process_block_filters(
            self.total_blocks-1, epoch)
        settled_layers = 0
        for src in range(1, len(lcs_src)):
            if lcs_src[src] >= 1:
                settled_layers += 1
        if self.algorithm_stage == 0:
            if settled_layers > 0:
                self.settled_layers_ceil = settled_layers
                self.algorithm_stage += 1
            elif (epoch-1) % self.asc_thresh == 0:
                self._new_layer(self.growth_rate)
        if self.algorithm_stage == 1:
            if epoch >= self.max_n_ep:
                continue_training = False
                self.algorithm_stage = 0
            elif settled_layers > self.settled_layers_ceil:
                self.settled_layers_ceil = settled_layers
                self._new_layer(self.growth_rate)
        return continue_training
def self_constructing_var1 ( self , epoch , accuracy ) : continue_training = True cs , lcs_dst , lcs_src = self . process_block_filters ( self . total_blocks - 1 , epoch ) settled_layers = 0 for src in range ( 1 , len ( lcs_src ) ) : if lcs_src [ src ] >= 1 : settled_layers += 1 if self . algorithm_stage == 0 : if settled_layers > 0 : self . settled_layers_ceil = settled_layers self . algorithm_stage += 1 elif ( epoch - 1 ) % self . asc_thresh == 0 : self . _new_layer ( self . growth_rate ) if self . algorithm_stage == 1 : if epoch >= self . max_n_ep : continue_training = False self . algorithm_stage = 0 elif settled_layers > self . settled_layers_ceil : self . settled_layers_ceil = settled_layers self . _new_layer ( self . growth_rate ) return continue_training
A step of the self-constructing algorithm (variant #1) for one
training epoch.
A step of the self - constructing algorithm ( variant #1 ) for one training epoch .
"""
        A step of the self-constructing algorithm (variant #1) for one
        training epoch.
        Adds new layers to the last block depending on parameters.
        Returns True if training should continue, False otherwise.

        This algorithm consists in a succession of two stages:
        - Ascension: add one layer every asc_thresh training epochs, break the
          loop (end the stage) when a layer settles (its layer cs for sources
          is == 1).
        - Improvement: end the stage when a total of max_n_ep epochs have
          elapsed (since the addition of the last block);
          if another layer settles, add a layer and restart the countdown.

        Args:
            epoch: `int`, current training epoch (since adding the last block);
            accuracy: `float`, accuracy for this epoch (here unused).
        """ # calculate number of settled layers (layers with lcs_src == 1) # stage #0 = ascension stage # stage #1 = improvement stage # stop algorithm and reset everything
self
epoch
`int`, current training epoch (since adding the last block).
` int ` current training epoch ( since adding the last block ) .
accuracy
`float`, accuracy for this epoch (here unused).
` float ` accuracy for this epoch ( here unused ) .