Where is the best place to put nn.Sequential?

Which one is more PyTorch like (better) code for nn.Sequential?

   def __init__(self):
       self.layers = nn.Sequential (layer1, layer2, ...)

   def forward(self, x):
       self.layers(x)

or

   def __init__(self):
       self.layer1, self.layer2, ...

   def forward(self, x):
       ss = nn.Sequential (layer1, layer2, ...)

Both would be okay?

You wouldn’t put it in such a structure. You could just write it as ss = nn.Sequential(layer1, activation, layer2, etc.)

nn.Sequential is a sequential container that allows you to build a neural network by specifying the sequential building blocks of the model.