WS-GM/nasbench201/utils.py
def update(self, epoch, ev, genotype, numparam=0):
        """ Method to update the local average list.

        Args:
            epoch (int): current epoch
            ev (float): current dominant eigenvalue
            genotype (namedtuple): current genotype

        """
        self.ev.append(ev)
        self.genotypes.update({epoch: genotype})
        self.numparams.update({epoch: numparam})
        # set the stop_genotype to the current genotype in case the early stop
        # procedure decides not to early stop
        self.stop_genotype = genotype

        # since the local average computation starts after the dominant
        # eigenvalue in the first epoch is already computed we have to wait
        # at least until we have 3 eigenvalues in the list.
        if (len(self.ev) >= int(np.ceil(self.window/2))) and (epoch <
                                                              self.epochs - 1):
            # start sliding the window as soon as the number of eigenvalues in
            # the list becomes equal to the window size
            if len(self.ev) < self.window:
                self.ev_local_avg.append(np.mean(self.ev))
            else:
                assert len(self.ev[self.la_start_idx: self.la_end_idx]) == self.window
                self.ev_local_avg.append(np.mean(self.ev[self.la_start_idx:
                                                         self.la_end_idx]))
                self.la_start_idx += 1
                self.la_end_idx += 1

            # keep track of the offset between the current epoch and the epoch
            # corresponding to the local average. NOTE: in the end the size of
            # self.ev and self.ev_local_avg should be equal
            self.la_epochs.update({epoch: int(epoch -
                                              int(self.ev_freq*np.floor(self.window/2)))})

        elif len(self.ev) < int(np.ceil(self.window/2)):
          self.la_epochs.update({epoch: -1})

        # since there is an offset between the current epoch and the local
        # average epoch, loop in the last epoch to compute the local average of
        # these number of elements: window, window - 1, window - 2, ..., ceil(window/2)
        elif epoch == self.epochs - 1:
            for i in range(int(np.ceil(self.window/2))):
                assert len(self.ev[self.la_start_idx: self.la_end_idx]) == self.window - i
                self.ev_local_avg.append(np.mean(self.ev[self.la_start_idx:
                                                         self.la_end_idx + 1]))
                self.la_start_idx += 1
 Method to update the local average list.

        Args:
            epoch (int): current epoch
            ev (float): current dominant eigenvalue
            genotype (namedtuple): current genotype

        
Method to update the local average list.
Method to update the local average list .
def update(self, epoch, ev, genotype, numparam=0):
        self.ev.append(ev)
        self.genotypes.update({epoch: genotype})
        self.numparams.update({epoch: numparam})
        self.stop_genotype = genotype
        if (len(self.ev) >= int(np.ceil(self.window/2))) and (epoch <
                                                              self.epochs - 1):
            if len(self.ev) < self.window:
                self.ev_local_avg.append(np.mean(self.ev))
            else:
                assert len(self.ev[self.la_start_idx: self.la_end_idx]) == self.window
                self.ev_local_avg.append(np.mean(self.ev[self.la_start_idx:
                                                         self.la_end_idx]))
                self.la_start_idx += 1
                self.la_end_idx += 1
            self.la_epochs.update({epoch: int(epoch -
                                              int(self.ev_freq*np.floor(self.window/2)))})
        elif len(self.ev) < int(np.ceil(self.window/2)):
          self.la_epochs.update({epoch: -1})
        elif epoch == self.epochs - 1:
            for i in range(int(np.ceil(self.window/2))):
                assert len(self.ev[self.la_start_idx: self.la_end_idx]) == self.window - i
                self.ev_local_avg.append(np.mean(self.ev[self.la_start_idx:
                                                         self.la_end_idx + 1]))
                self.la_start_idx += 1
def update ( self , epoch , ev , genotype , numparam = 0 ) : self . ev . append ( ev ) self . genotypes . update ( { epoch : genotype } ) self . numparams . update ( { epoch : numparam } ) self . stop_genotype = genotype if ( len ( self . ev ) >= int ( np . ceil ( self . window / 2 ) ) ) and ( epoch < self . epochs - 1 ) : if len ( self . ev ) < self . window : self . ev_local_avg . append ( np . mean ( self . ev ) ) else : assert len ( self . ev [ self . la_start_idx : self . la_end_idx ] ) == self . window self . ev_local_avg . append ( np . mean ( self . ev [ self . la_start_idx : self . la_end_idx ] ) ) self . la_start_idx += 1 self . la_end_idx += 1 self . la_epochs . update ( { epoch : int ( epoch - int ( self . ev_freq * np . floor ( self . window / 2 ) ) ) } ) elif len ( self . ev ) < int ( np . ceil ( self . window / 2 ) ) : self . la_epochs . update ( { epoch : - 1 } ) elif epoch == self . epochs - 1 : for i in range ( int ( np . ceil ( self . window / 2 ) ) ) : assert len ( self . ev [ self . la_start_idx : self . la_end_idx ] ) == self . window - i self . ev_local_avg . append ( np . mean ( self . ev [ self . la_start_idx : self . la_end_idx + 1 ] ) ) self . la_start_idx += 1
Method to update the local average list.
Method to update the local average list .
""" Method to update the local average list.

        Args:
            epoch (int): current epoch
            ev (float): current dominant eigenvalue
            genotype (namedtuple): current genotype

        """ # set the stop_genotype to the current genotype in case the early stop # procedure decides not to early stop # since the local average computation starts after the dominant # eigenvalue in the first epoch is already computed we have to wait # at least until we have 3 eigenvalues in the list. # start sliding the window as soon as the number of eigenvalues in # the list becomes equal to the window size # keep track of the offset between the current epoch and the epoch # corresponding to the local average. NOTE: in the end the size of # self.ev and self.ev_local_avg should be equal # since there is an offset between the current epoch and the local # average epoch, loop in the last epoch to compute the local average of # these number of elements: window, window - 1, window - 2, ..., ceil(window/2)
self
epoch
None
ev
current dominant eigenvalue
current dominant eigenvalue
genotype
None
numparam