(self, dir_logs, name, model, optimizer, map_location=None)
Load a checkpoint

            Args:
                dir_logs: directory of the checkpoint
                name: name of the checkpoint
                model: model associated to the checkpoint
                optimizer: optimizer associated to the checkpoint
Load a checkpoint
Load a checkpoint
def load(self, dir_logs, name, model, optimizer, map_location=None):
        """ Load a checkpoint

            Args:
                dir_logs: directory of the checkpoint
                name: name of the checkpoint
                model: model associated to the checkpoint
                optimizer: optimizer associated to the checkpoint
        """
        path_template = os.path.join(dir_logs, 'ckpt_{}_{}.pth.tar')

        Logger()('Loading model...')
        model_state = torch.load(path_template.format(name, 'model'), map_location=map_location)
        model.load_state_dict(model_state)

        if Options()['dataset']['train_split'] is not None:
            if os.path.isfile(path_template.format(name, 'optimizer')):
                Logger()('Loading optimizer...')
                optimizer_state = torch.load(path_template.format(name, 'optimizer'), map_location=map_location)
                optimizer.load_state_dict(optimizer_state)
            else:
                Logger()('No optimizer checkpoint', log_level=Logger.WARNING)

        if os.path.isfile(path_template.format(name, 'engine')):
            Logger()('Loading engine...')
            engine_state = torch.load(path_template.format(name, 'engine'), map_location=map_location)
            self.load_state_dict(engine_state)
        else:
            Logger()('No engine checkpoint', log_level=Logger.WARNING)
def load ( self , dir_logs , name , model , optimizer , map_location = None ) : path_template = os . path . join ( dir_logs , 'ckpt_{}_{}.pth.tar' ) Logger ( ) ( 'Loading model...' ) model_state = torch . load ( path_template . format ( name , 'model' ) , map_location = map_location ) model . load_state_dict ( model_state ) if Options ( ) [ 'dataset' ] [ 'train_split' ] is not None : if os . path . isfile ( path_template . format ( name , 'optimizer' ) ) : Logger ( ) ( 'Loading optimizer...' ) optimizer_state = torch . load ( path_template . format ( name , 'optimizer' ) , map_location = map_location ) optimizer . load_state_dict ( optimizer_state ) else : Logger ( ) ( 'No optimizer checkpoint' , log_level = Logger . WARNING ) if os . path . isfile ( path_template . format ( name , 'engine' ) ) : Logger ( ) ( 'Loading engine...' ) engine_state = torch . load ( path_template . format ( name , 'engine' ) , map_location = map_location ) self . load_state_dict ( engine_state ) else : Logger ( ) ( 'No engine checkpoint' , log_level = Logger . WARNING )