Truncate a model made from nn.ModuleList


I have a model created using nn.ModuleList. Is it possible truncate the model like

model = torch.load(‘load the tiramisu model’)


a truncated model till the bottleneck

As far as I can tell there isn’t a way to do this easily: .
Feel free to send a feature request to

On second thought, because ModuleList inherits from Module, you could use the delattr of a module to get rid of the modules you don’t want in your list.

@richard Thank you shedding some light on delattr. It was able to delete/ remove the modules, however I am forced to change the forward function of the model. If I dont do it, it would give an error.