I found several threads on this topic but the most let me think: “There has to be an easier way to achieve it”.
So what do I want to do?
I load a pretrained VGG-16-Model and send my imagedata through the model.
Now I want to build hypercolums from different layers of the model. Like in this paper:

  
      arxiv.org
  
  
    
1604.01347.pdf 5

5.08 MB

  
  
    
    
  
  


But how can I achieve it?
My Net looks like this:
class Net(nn.Module):

	def __init__(self, vgg):
		super(Net, self).__init__()
		self.vgg = vgg
		
		self.classifier = nn.Sequential(
			nn.Linear(153600, 4096), # I know this classifiers are not correct. But first I want to get the hypercolums.
			nn.ReLU(True),
			nn.Linear(4096, 4096),
			nn.ReLU(True),
			nn.Linear(4096, 3),
		)

	def forward(self, x):
		x = self.features(x)
                # Here I have to get the pixel information of several layers like
                for layers in self.layers:
                        if self.layer in [5,8,15,22]:
                                 #make a tensor to save all pixel information in and resize to input image size
                                 # add tensor to tensor of previous layers.
                # and then the resulting tensor should be send to the classifiers
		x = self.classifier(x)

Is there an easy way to get the hypercolums?