I don’t know how Model is defined but assuming that self.layer_name gets an intermediate activation from ResNet50, you could either use forward hooks as described here 2 or override the forward of the resnet implementation so that the desired activation will be returned.