修改pt,生成新的pt文件,删除带有up的层。

import torch

device = 'cpu'
new_state={}
state_dict = torch.load('../pretrained_models/1000000_G.pth',map_location=device)
for name,layer in state_dict.items():
    if 'up' not in name:
        print(name)
        #print(layer)
        new_state[name]=layer

torch.save(new_state,'./100w_new.pth')

猜你喜欢

转载自blog.csdn.net/qq_40962125/article/details/134260075
pt