Closed chenwuxing closed 5 years ago
Hello, I have used model.children() to delete the last fc layer in resnet.
import torch from torchvision import models resnet50 = models.resnet50(pretrained=True) resnet_reducefc = torch.nn.Sequential(*list(resnet50.children())[:-2]) torch.save(resnet_reducefc.state_dict(),"f:/resnet50.pth")
But when I run these code will get a error:
res_para = torch.load("f:/resnet50.pth") res.load_state_dict(res_para)
I think the reason may be that I use nn.sequential() to save model file, but now I don't have a good idea to deal these problem. could you give me some help,thank you!
Hello, I have used model.children() to delete the last fc layer in resnet.
But when I run these code will get a error:
I think the reason may be that I use nn.sequential() to save model file, but now I don't have a good idea to deal these problem. could you give me some help,thank you!