Solved by ptrblck in post #2 
              
              
                You could create a custom submodule inside your main module: 
class MySubmodule(nn.Module):
    def __init__(self):
        super(MySubmodule, self).__init__()
        self.feat1 = nn.Conv2d(1, 1, 3, 1, 1)
        # ...
        
    def forward(self, x):
        x = self.feat1(x)
        return x
  …