models/dense_net.py
def print_pertinent_features(self, loss, accuracy, epoch, validation_set):
        """
        Prints on console the current values of pertinent features.
        The loss and accuracy are those on the validation set if such a set is
        being used, otherwise they are those on the training set.
        If feature logs are being saved, this function saves feature values.
        If images are being saved, it also saves filter features as images.

        Args:
            loss: `list` of `float` (if validation_set == True, else `float`),
                loss (cross_entropy) for this epoch, in some cases (as `list`
                of `float`) contains several loss values, each corresponding to
                each internal layer of the last block;
            accuracy: `float`, accuracy for this epoch;
            epoch: `int`, current training epoch;
            validation_set: `bool`, whether a validation set is used or not.
        """
        # print the current accuracy
        print("Current accuracy = %f" % accuracy)
        if validation_set:
            # print a cross-entropy value for each layer, if calculating them
            if self.ft_cross_entropies:
                print("Cross-entropy per layer in block #%d:" % (
                    self.total_blocks-1))
                for l in range(len(loss)):
                    print("* Layer #%d: cross-entropy = %f" % (l, loss[l]))
            # else print only the current validation cross-entropy
            else:
                print("Current cross-entropy = %f" % loss[-1])
        else:
            print("Current cross-entropy = %f" % loss)

        if self.should_save_ft_logs:
            # save the previously printed feature values
            self.feature_writer.write(("\"%d\"%s\"%f\"%s" % (
                epoch, self.ftc, accuracy, self.ftc)).replace(".", self.ftd))
            if validation_set:
                for l in range(len(loss)):
                    self.feature_writer.write(("\"%f\"%s" % (loss[l], self.ftc)
                                               ).replace(".", self.ftd))
            else:
                self.feature_writer.write(("\"%f\"%s" % (loss, self.ftc)
                                           ).replace(".", self.ftd))
            self.feature_writer.write('\"\"')

        if self.ft_filters:
            # process filters, sometimes save their state as images
            print('-' * 40 + "\nProcessing filters:")
            print('\n* Global input data (post-processed):')
            for b in range(0, self.total_blocks):
                cs, lcs_dst, lcs_src = self.process_block_filters(b, epoch)
                self.ft_log_filters(b, cs, lcs_dst, lcs_src)
        elif self.ft_kernels:
            # process kernels instead
            print('-' * 40 + "\nProcessing kernels:")
            for b in range(0, self.total_blocks):
                for l in range(0, self.layer_num_list[b]):
                    print('\n* Block %d filter %d:' % (b, l))
                    cs = self.process_layer_kernels(b, l, epoch)
                    for k in range(len(cs)):
                        print('  - Kernel %d: CS = %f' % (k, cs[k]))
                    if self.should_save_ft_logs:
                        for k in range(len(cs)):
                            self.feature_writer.write((
                                '%s\"%f\"' % (self.ftc, cs[k])).replace(
                                    ".", self.ftd))
                        self.feature_writer.write('%s\"\"' % self.ftc)

        print('-' * 40)
        if self.should_save_ft_logs:
            self.feature_writer.write('\n')

        Prints on console the current values of pertinent features.
        The loss and accuracy are those on the validation set if such a set is
        being used, otherwise they are those on the training set.
        If feature logs are being saved, this function saves feature values.
        If images are being saved, it also saves filter features as images.

        Args:
            loss: `list` of `float` (if validation_set == True, else `float`),
                loss (cross_entropy) for this epoch, in some cases (as `list`
                of `float`) contains several loss values, each corresponding to
                each internal layer of the last block;
            accuracy: `float`, accuracy for this epoch;
            epoch: `int`, current training epoch;
            validation_set: `bool`, whether a validation set is used or not.
        
Prints on console the current values of pertinent features.
The loss and accuracy are those on the validation set if such a set is
being used, otherwise they are those on the training set.
If feature logs are being saved, this function saves feature values.
If images are being saved, it also saves filter features as images.
Prints on console the current values of pertinent features . The loss and accuracy are those on the validation set if such a set is being used otherwise they are those on the training set . If feature logs are being saved this function saves feature values . If images are being saved it also saves filter features as images .
def print_pertinent_features(self, loss, accuracy, epoch, validation_set):
        print("Current accuracy = %f" % accuracy)
        if validation_set:
            if self.ft_cross_entropies:
                print("Cross-entropy per layer in block #%d:" % (
                    self.total_blocks-1))
                for l in range(len(loss)):
                    print("* Layer #%d: cross-entropy = %f" % (l, loss[l]))
            else:
                print("Current cross-entropy = %f" % loss[-1])
        else:
            print("Current cross-entropy = %f" % loss)
        if self.should_save_ft_logs:
            self.feature_writer.write(("\"%d\"%s\"%f\"%s" % (
                epoch, self.ftc, accuracy, self.ftc)).replace(".", self.ftd))
            if validation_set:
                for l in range(len(loss)):
                    self.feature_writer.write(("\"%f\"%s" % (loss[l], self.ftc)
                                               ).replace(".", self.ftd))
            else:
                self.feature_writer.write(("\"%f\"%s" % (loss, self.ftc)
                                           ).replace(".", self.ftd))
            self.feature_writer.write('\"\"')
        if self.ft_filters:
            print('-' * 40 + "\nProcessing filters:")
            print('\n* Global input data (post-processed):')
            for b in range(0, self.total_blocks):
                cs, lcs_dst, lcs_src = self.process_block_filters(b, epoch)
                self.ft_log_filters(b, cs, lcs_dst, lcs_src)
        elif self.ft_kernels:
            print('-' * 40 + "\nProcessing kernels:")
            for b in range(0, self.total_blocks):
                for l in range(0, self.layer_num_list[b]):
                    print('\n* Block %d filter %d:' % (b, l))
                    cs = self.process_layer_kernels(b, l, epoch)
                    for k in range(len(cs)):
                        print('  - Kernel %d: CS = %f' % (k, cs[k]))
                    if self.should_save_ft_logs:
                        for k in range(len(cs)):
                            self.feature_writer.write((
                                '%s\"%f\"' % (self.ftc, cs[k])).replace(
                                    ".", self.ftd))
                        self.feature_writer.write('%s\"\"' % self.ftc)
        print('-' * 40)
        if self.should_save_ft_logs:
            self.feature_writer.write('\n')
def print_pertinent_features ( self , loss , accuracy , epoch , validation_set ) : print ( "Current accuracy = %f" % accuracy ) if validation_set : if self . ft_cross_entropies : print ( "Cross-entropy per layer in block #%d:" % ( self . total_blocks - 1 ) ) for l in range ( len ( loss ) ) : print ( "* Layer #%d: cross-entropy = %f" % ( l , loss [ l ] ) ) else : print ( "Current cross-entropy = %f" % loss [ - 1 ] ) else : print ( "Current cross-entropy = %f" % loss ) if self . should_save_ft_logs : self . feature_writer . write ( ( "\"%d\"%s\"%f\"%s" % ( epoch , self . ftc , accuracy , self . ftc ) ) . replace ( "." , self . ftd ) ) if validation_set : for l in range ( len ( loss ) ) : self . feature_writer . write ( ( "\"%f\"%s" % ( loss [ l ] , self . ftc ) ) . replace ( "." , self . ftd ) ) else : self . feature_writer . write ( ( "\"%f\"%s" % ( loss , self . ftc ) ) . replace ( "." , self . ftd ) ) self . feature_writer . write ( '\"\"' ) if self . ft_filters : print ( '-' * 40 + "\nProcessing filters:" ) print ( '\n* Global input data (post-processed):' ) for b in range ( 0 , self . total_blocks ) : cs , lcs_dst , lcs_src = self . process_block_filters ( b , epoch ) self . ft_log_filters ( b , cs , lcs_dst , lcs_src ) elif self . ft_kernels : print ( '-' * 40 + "\nProcessing kernels:" ) for b in range ( 0 , self . total_blocks ) : for l in range ( 0 , self . layer_num_list [ b ] ) : print ( '\n* Block %d filter %d:' % ( b , l ) ) cs = self . process_layer_kernels ( b , l , epoch ) for k in range ( len ( cs ) ) : print ( '  - Kernel %d: CS = %f' % ( k , cs [ k ] ) ) if self . should_save_ft_logs : for k in range ( len ( cs ) ) : self . feature_writer . write ( ( '%s\"%f\"' % ( self . ftc , cs [ k ] ) ) . replace ( "." , self . ftd ) ) self . feature_writer . write ( '%s\"\"' % self . ftc ) print ( '-' * 40 ) if self . should_save_ft_logs : self . feature_writer . write ( '\n' )
Prints on console the current values of pertinent features.
Prints on console the current values of pertinent features .
"""
        Prints on console the current values of pertinent features.
        The loss and accuracy are those on the validation set if such a set is
        being used, otherwise they are those on the training set.
        If feature logs are being saved, this function saves feature values.
        If images are being saved, it also saves filter features as images.

        Args:
            loss: `list` of `float` (if validation_set == True, else `float`),
                loss (cross_entropy) for this epoch, in some cases (as `list`
                of `float`) contains several loss values, each corresponding to
                each internal layer of the last block;
            accuracy: `float`, accuracy for this epoch;
            epoch: `int`, current training epoch;
            validation_set: `bool`, whether a validation set is used or not.
        """ # print the current accuracy # print a cross-entropy value for each layer, if calculating them # else print only the current validation cross-entropy # save the previously printed feature values # process filters, sometimes save their state as images # process kernels instead
self
loss
`list` of `float` (if validation_set == True, else `float`),
loss (cross_entropy) for this epoch, in some cases (as `list`
of `float`) contains several loss values, each corresponding to
each internal layer of the last block.
` list ` of ` float ` ( if validation_set == True else ` float ` ) loss ( cross_entropy ) for this epoch in some cases ( as ` list ` of ` float ` ) contains several loss values each corresponding to each internal layer of the last block .
accuracy
`float`, accuracy for this epoch.
` float ` accuracy for this epoch .
epoch
`int`, current training epoch.
` int ` current training epoch .
validation_set
`bool`, whether a validation set is used or not.
` bool ` whether a validation set is used or not .