You could wrap the linear and dropout layer into an nn.Sequential module and append it to the nn.ModuleList. However, for more complicated constructs I would probably just use the for loop for the sake of readability. It’ll be executed once during the model initialization so I would claim no performance impact would be visible as it’s not in the hot path.