Extracting output from intermediate layers in Inceptionv3

I am trying to extract output from the middle layer of Inception v3. I tried using

model = models.inception_v3(pretrained=True)
def get_features(name):
    def hook(model, input, output):
        features[name] = output.detach()

    return hook


model.global_pool.register_forward_hook(get_features("feats"))

although this produces an error:

“”"
‘Inception3’ object has no attribute ‘global_pool’
“”"

does anyone know some other way I can take out the features from this

As the error message explains, the model does not have a .global_pool attribute, so you might confuse it with .avgpool.