(self, epoch, model)
Save history
Save history
Save history
def save_history(self, epoch, model):
        """
        Save history
        """
        # if history > 1, this function will save the last N checkpoints
        # where N is equal to self.history.  The files will have the form
        # of save_path with the epoch added to the filename before the ext

        if len(self.checkpoint_files) > self.history:
            # remove oldest checkpoint file when max count have been saved
            fn = self.checkpoint_files.popleft()
            try:
                os.remove(fn)
                logger.info('removed old checkpoint %s' % fn)
            except OSError:
                logger.warn('Could not delete old checkpoint file %s' % fn)

        path_split = os.path.splitext(self.save_path)
        save_path = '%s_%d%s' % (path_split[0], epoch, path_split[1])
        # add the current file to the deque
        self.checkpoint_files.append(save_path)
        save_obj(model.serialize(keep_states=True), save_path)

        # maintain a symlink pointing to the latest model params
        try:
            if os.path.islink(self.save_path):
                os.remove(self.save_path)
            os.symlink(os.path.split(save_path)[-1], self.save_path)
        except OSError:
            logger.warn('Could not create latest model symlink %s -> %s'
                        % (self.save_path, save_path))
def save_history ( self , epoch , model ) : # if history > 1, this function will save the last N checkpoints # where N is equal to self.history.  The files will have the form # of save_path with the epoch added to the filename before the ext if len ( self . checkpoint_files ) > self . history : # remove oldest checkpoint file when max count have been saved fn = self . checkpoint_files . popleft ( ) try : os . remove ( fn ) logger . info ( 'removed old checkpoint %s' % fn ) except OSError : logger . warn ( 'Could not delete old checkpoint file %s' % fn ) path_split = os . path . splitext ( self . save_path ) save_path = '%s_%d%s' % ( path_split [ 0 ] , epoch , path_split [ 1 ] ) # add the current file to the deque self . checkpoint_files . append ( save_path ) save_obj ( model . serialize ( keep_states = True ) , save_path ) # maintain a symlink pointing to the latest model params try : if os . path . islink ( self . save_path ) : os . remove ( self . save_path ) os . symlink ( os . path . split ( save_path ) [ - 1 ] , self . save_path ) except OSError : logger . warn ( 'Could not create latest model symlink %s -> %s' % ( self . save_path , save_path ) )