models/dense_net.py
def self_constructing_minimal(self, epoch, accuracy):
        """
        A step of the self-constructing algorithm (minimal kernel-by-kernel
        variant) for one training epoch.
        Builds new layers in the last block depending on parameters.
        Returns True if training should continue, False otherwise.

        The algorithm is meant to be run with an initial architecture of 1
        layer with 1 kernel. It only adds an additional kernel to the
        layer after m_asc_thresh epochs, then ends after performing a patience
        countdown (to further train the network). This is meant to represent a
        "minimal" kernel-level self-construction.

        Args:
            epoch: `int`, current training epoch (since adding the last block);
            accuracy: `float`, accuracy for this epoch.
        """
        continue_training = True

        # Update the kernel CS lists
        cs_kernels = self.process_layer_kernels(
            self.total_blocks-1, self.layer_num_list[-1]-1, epoch)
        for k in range(len(self.kCS_FIFO)):
            self.kCS_FIFO[k].append(cs_kernels[k])

        # stage #0 = ascension stage (currently does nothing)
        if self.algorithm_stage == 0:
            self.algorithm_stage += 1

        # stage #1 = improvement stage
        if self.algorithm_stage == 1:
            # micro-stage #0 = minimal micro-ascension stage
            if self.micro_stage == 0:
                if len(self.kernels_ref_list[-1][-1]) >= 3:
                    # end stage when there are at least two kernels.
                    self.micro_stage += 1
                    # max_n_ep is used to estimate completion time
                    self.max_n_ep = epoch + self.m_patience_param + 1
                elif (epoch-1) % self.m_asc_thresh == 0:
                    self._new_kernels_to_last_layer(
                        self.expansion_rate,
                        complementarity=self.complementarity)

            # micro-stage #1 = patience countdown
            if self.micro_stage == 1:
                if self.m_patience_cntdwn <= 0:
                    # reset everything for the micro-algorithm
                    self.micro_stage = 0
                    self.useful_kernels_ceil = 0
                    self.m_patience_cntdwn = self.m_patience_param
                    # at the end of the patience countdown, end macro-stage
                    self.algorithm_stage += 1
                else:
                    # patience countdown progress
                    self.m_patience_cntdwn -= 1

        # stage #2 (nothing yet, stop the algorithm and reset everything)
        if self.algorithm_stage == 2:
            continue_training = False
            self.algorithm_stage = 0
            self.patience_cntdwn = self.patience_param
            self.accuracy_last_layer = 0

        return continue_training

        A step of the self-constructing algorithm (minimal kernel-by-kernel
        variant) for one training epoch.
        Builds new layers in the last block depending on parameters.
        Returns True if training should continue, False otherwise.

        The algorithm is meant to be run with an initial architecture of 1
        layer with 1 kernel. It only adds an additional kernel to the
        layer after m_asc_thresh epochs, then ends after performing a patience
        countdown (to further train the network). This is meant to represent a
        "minimal" kernel-level self-construction.

        Args:
            epoch: `int`, current training epoch (since adding the last block);
            accuracy: `float`, accuracy for this epoch.
        
A step of the self-constructing algorithm (minimal kernel-by-kernel
variant) for one training epoch.
Builds new layers in the last block depending on parameters.
Returns True if training should continue, False otherwise.

The algorithm is meant to be run with an initial architecture of 1
layer with 1 kernel. It only adds an additional kernel to the
layer after m_asc_thresh epochs, then ends after performing a patience
countdown (to further train the network). This is meant to represent a
"minimal" kernel-level self-construction.
A step of the self - constructing algorithm ( minimal kernel - by - kernel variant ) for one training epoch . Builds new layers in the last block depending on parameters . Returns True if training should continue False otherwise . The algorithm is meant to be run with an initial architecture of 1 layer with 1 kernel . It only adds an additional kernel to the layer after m_asc_thresh epochs then ends after performing a patience countdown ( to further train the network ) . This is meant to represent a " minimal " kernel - level self - construction .
def self_constructing_minimal(self, epoch, accuracy):
        continue_training = True
        cs_kernels = self.process_layer_kernels(
            self.total_blocks-1, self.layer_num_list[-1]-1, epoch)
        for k in range(len(self.kCS_FIFO)):
            self.kCS_FIFO[k].append(cs_kernels[k])
        if self.algorithm_stage == 0:
            self.algorithm_stage += 1
        if self.algorithm_stage == 1:
            if self.micro_stage == 0:
                if len(self.kernels_ref_list[-1][-1]) >= 3:
                    self.micro_stage += 1
                    self.max_n_ep = epoch + self.m_patience_param + 1
                elif (epoch-1) % self.m_asc_thresh == 0:
                    self._new_kernels_to_last_layer(
                        self.expansion_rate,
                        complementarity=self.complementarity)
            if self.micro_stage == 1:
                if self.m_patience_cntdwn <= 0:
                    self.micro_stage = 0
                    self.useful_kernels_ceil = 0
                    self.m_patience_cntdwn = self.m_patience_param
                    self.algorithm_stage += 1
                else:
                    self.m_patience_cntdwn -= 1
        if self.algorithm_stage == 2:
            continue_training = False
            self.algorithm_stage = 0
            self.patience_cntdwn = self.patience_param
            self.accuracy_last_layer = 0
        return continue_training
def self_constructing_minimal ( self , epoch , accuracy ) : continue_training = True cs_kernels = self . process_layer_kernels ( self . total_blocks - 1 , self . layer_num_list [ - 1 ] - 1 , epoch ) for k in range ( len ( self . kCS_FIFO ) ) : self . kCS_FIFO [ k ] . append ( cs_kernels [ k ] ) if self . algorithm_stage == 0 : self . algorithm_stage += 1 if self . algorithm_stage == 1 : if self . micro_stage == 0 : if len ( self . kernels_ref_list [ - 1 ] [ - 1 ] ) >= 3 : self . micro_stage += 1 self . max_n_ep = epoch + self . m_patience_param + 1 elif ( epoch - 1 ) % self . m_asc_thresh == 0 : self . _new_kernels_to_last_layer ( self . expansion_rate , complementarity = self . complementarity ) if self . micro_stage == 1 : if self . m_patience_cntdwn <= 0 : self . micro_stage = 0 self . useful_kernels_ceil = 0 self . m_patience_cntdwn = self . m_patience_param self . algorithm_stage += 1 else : self . m_patience_cntdwn -= 1 if self . algorithm_stage == 2 : continue_training = False self . algorithm_stage = 0 self . patience_cntdwn = self . patience_param self . accuracy_last_layer = 0 return continue_training
A step of the self-constructing algorithm (minimal kernel-by-kernel
variant) for one training epoch.
A step of the self - constructing algorithm ( minimal kernel - by - kernel variant ) for one training epoch .
"""
        A step of the self-constructing algorithm (minimal kernel-by-kernel
        variant) for one training epoch.
        Builds new layers in the last block depending on parameters.
        Returns True if training should continue, False otherwise.

        The algorithm is meant to be run with an initial architecture of 1
        layer with 1 kernel. It only adds an additional kernel to the
        layer after m_asc_thresh epochs, then ends after performing a patience
        countdown (to further train the network). This is meant to represent a
        "minimal" kernel-level self-construction.

        Args:
            epoch: `int`, current training epoch (since adding the last block);
            accuracy: `float`, accuracy for this epoch.
        """ # Update the kernel CS lists # stage #0 = ascension stage (currently does nothing) # stage #1 = improvement stage # micro-stage #0 = minimal micro-ascension stage # end stage when there are at least two kernels. # max_n_ep is used to estimate completion time # micro-stage #1 = patience countdown # reset everything for the micro-algorithm # at the end of the patience countdown, end macro-stage # patience countdown progress # stage #2 (nothing yet, stop the 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.
` float ` accuracy for this epoch .