Solved by vmirly1 in post #2 
              
              
                Maybe you can use the ModuleDict for naming the layers. I have a simple example: 
import torch.nn as nn

class MyModule(nn.Module):
    def __init__(self):
        super(MyModule, self).__init__()
        self.model = nn.ModuleDict({
                'conv1': nn.Conv2d(1, 8, 3, padding=1),
          …