Why the use of nn.Sequential(nn.Sequential())

Hi, I need some help understanding this code:

model = nn.Sequential(
nn.Sequential(full.layer0, full.layer1, full.layer2, full.layer3[:3]),
nn.Sequential(full.layer3[3:], full.layer4),
get_head(2048, n_classes))

Why not do something like:

model = nn.Sequential(
full.layer0, full.layer1, full.layer2, full.layer3,
get_head(2048, n_classes))

Thank you for the help


The only possible reason I can see is if you want to only train the last layers and you want to pass these parameters to the optimizer with model[1].parameters().
Otherwise. I don’t really see a good reason to do this.

1 Like