Hi, I would like to get outputs from multiple layers of a pretrained VGG-16 network. Following is what I have done:
model = torchvision.models.vgg16()

# make new models to extract features
layers = list(model.children())[0][:8]
model_conv22 = nn.Sequential(*layers)  

layers = list(model.children())[0][:15]
model_conv33 = nn.Sequential(*layers)   

layers = list(model.children())[0][:22]
model_conv43 = nn.Sequential(*layers) 

layers = list(model.children())[0][:29]
model_conv53 = nn.Sequential(*layers)  

# get outputs
x1 = model_conv22(input)   
x2 = model_conv33(input)   
x3 = model_conv43(input)   
x4 = model_conv53(input)

I know that this is not an intelligent way. Could you give me some ideas to make it efficient?
Thank you very much.