(resume_path, model=None)
return [model,best,start_epoch]
加载模型
    :param resume_path:
    :param model:
    :param optimizer:
    :return:
    注意： 如果是加载Bert模型的话，需要调整，不能使用该模式
    可以使用模块自带的Bert_model.from_pretrained(state_dict = your save state_dict)
加载模型
    :param resume_path:
    :param model:
    :param optimizer:
    :return:
    注意： 如果是加载Bert模型的话，需要调整，不能使用该模式
    可以使用模块自带的Bert_model.from_pretrained(state_dict = your save state_dict)
加载模型 : param resume_path : : param model : : param optimizer : : return : 注意： 如果是加载Bert模型的话，需要调整，不能使用该模式 可以使用模块自带的Bert_model . from_pretrained ( state_dict = your save state_dict )
def restore_checkpoint(resume_path, model=None):
    '''
    加载模型
    :param resume_path:
    :param model:
    :param optimizer:
    :return:
    注意： 如果是加载Bert模型的话，需要调整，不能使用该模式
    可以使用模块自带的Bert_model.from_pretrained(state_dict = your save state_dict)
    '''
    if isinstance(resume_path, Path):
        resume_path = str(resume_path)
    checkpoint = torch.load(resume_path)
    best = checkpoint['best']
    start_epoch = checkpoint['epoch'] + 1
    states = checkpoint['state_dict']
    if isinstance(model, nn.DataParallel):
        model.module.load_state_dict(states)
    else:
        model.load_state_dict(states)
    return [model,best,start_epoch]
def restore_checkpoint ( resume_path , model = None ) : if isinstance ( resume_path , Path ) : resume_path = str ( resume_path ) checkpoint = torch . load ( resume_path ) best = checkpoint [ 'best' ] start_epoch = checkpoint [ 'epoch' ] + 1 states = checkpoint [ 'state_dict' ] if isinstance ( model , nn . DataParallel ) : model . module . load_state_dict ( states ) else : model . load_state_dict ( states ) return [ model , best , start_epoch ]