Use loop to define network

what about this?

x = getattr(self,  'l' + str(i))

Alternatively, you can use nn.ModuleList

1 Like