Hello,
l would like to extract features (last fully connected layer) from  a fine tuned pretrained resnet152 on my own dataset.
In order to extract features from the original pretrained resnet152 model l  did simply the following :

resnet152 = models.resnet152(pretrained=True)
modules = list(resnet152.children())[:-1]
resnet152 = nn.Sequential(*modules)
resnet152.cuda()
resnet152.eval()
for name in files:
        open_img = Image.open(os.path.join(root, name))
        image = ToTensor()(open_img).unsqueeze(0)
        image = image.cuda()
        img_var = Variable(image)
        features_var = resnet152(img_var)


However, when l train Resnet152 from scratch on my custom dataset. I store my model as model_best.pth.tar
And load it as follow :
resnet152=torch.load('/local/model_best.pth.tar')
but can’t get children by doing :
modules = list(resnet152.children())[:-1]
l tried :
resnet152=resnet152[u'state_dict']
However, how can l specify that l want to extract features from the last layer ?
l  tried then to do that with hook function as follow :
activation = {}
def get_activation(name):
    def hook(model, input, output):
        activation[name] = output.detach()

    return hook

But, resnet152.fc.register_forward_hook(get_activation('fc')) is not recognized
Any cue please  !!