1,如何修改模型的某个层的参数?

1,获取模型参数的键值对?

import torch
model_path = r'./your_model'
model_dicts = torch.load(model_path,map_location=torch.device('cpu'))
print(model_dicts)
for key,value in model_dicts.items():
    print(key)
    """
    modify values
    """
model = create_your_model()
model.load_state_dict(model_dicts,strict=True)

你可能感兴趣的:(学习,深度学习,pytorch)