Truncate a model made from nn.ModuleList

Hi;

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

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

required:

a truncated model till the bottleneck

As far as I can tell there isn’t a way to do this easily: http://pytorch.org/docs/master/_modules/torch/nn/modules/container.html#ModuleList .
Feel free to send a feature request to https://github.com/pytorch/pytorch/issues/

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.