go through the thread to learn how to do it.

  
    
    
    How to extract features of an image from a trained model 
  
  
    @kpar Yes, it’s possible and very easy in PyTorch. All you need to do is to return the multiple outputs that you want to retrieve. 
Here is an example 
class Net(nn.Module):
    def __init__(self):
        self.conv1 = nn.Conv2d(1, 1, 3)
        self.conv2 = nn.Conv2d(1, 1, 3)
        self.conv3 = nn.Conv2d(1, 1, 3)

    def forward(self, x):
        out1 = F.relu(self.conv1(x))
        out2 = F.relu(self.conv2(out1))
        out3 = F.relu(self.conv3(out2))
        return out1, out2, out3