I have a train model,the architecture of the model as shown in the following:

def forward(self, x):
x = F.relu(F.max_pool2d(self.conv1(x), 2))
x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))
x = F.relu(F.max_pool2d(self.conv3(x), 2))
x = F.relu(F.max_pool2d(self.conv4_drop(self.conv4(x)), 2))
x = x.view(-1, 160)
return x

How can I get the middle layer’s output of in the test processing?

Can anyone give me some suggestions?
Thank you so much.

variation on richard’s approach: simply return the xns you want, like:

return x4, x3, x2, x1

There is no rule/law that says that network modules need to return one and only one tensor.

(You can also return a list or a dictionary too by the way; I mean, you can return anything you like in fact; this is true for input parameters too by the way: you can have as many or as few input parameters as you want, and of any type you find works well for you)