I was trying to remove the last layer (fc) of Resnet18 to create something like this by using the following

```
pretrained_model = models.resnet18(pretrained=True)
for param in pretrained_model.parameters():
param.requires_grad = False
my_model = nn.Sequential(*list(pretrained_model.modules())[:-1])
model = MyModel(my_model)
```

As it turns out this did not work (the layer is still there in the new model). I then found this post and used the below line which works.

```
my_model = nn.Sequential(*list(pretrained_model.children())[:-1])
```

What is the difference between the two and why does one work but not the other?