(model, model_path)
存储不含有显卡信息的state_dict或model
    :param model:
    :param model_name:
    :param only_param:
    :return:
存储不含有显卡信息的state_dict或model
    :param model:
    :param model_name:
    :param only_param:
    :return:
存储不含有显卡信息的state_dict或model : param model : : param model_name : : param only_param : : return :
def save_model(model, model_path):
    """ 存储不含有显卡信息的state_dict或model
    :param model:
    :param model_name:
    :param only_param:
    :return:
    """
    if isinstance(model_path, Path):
        model_path = str(model_path)
    if isinstance(model, nn.DataParallel):
        model = model.module
    state_dict = model.state_dict()
    for key in state_dict:
        state_dict[key] = state_dict[key].cpu()
    torch.save(state_dict, model_path)
def save_model ( model , model_path ) : if isinstance ( model_path , Path ) : model_path = str ( model_path ) if isinstance ( model , nn . DataParallel ) : model = model . module state_dict = model . state_dict ( ) for key in state_dict : state_dict [ key ] = state_dict [ key ] . cpu ( ) torch . save ( state_dict , model_path )