Solved by ptrblck in post #2 
              
              
                That’s a weird issue. 
I tried to reproduce it using your code snippets, but they seem to work fine: 
class SiameseNetwork(nn.Module):
    def __init__(self):
        super(SiameseNetwork, self).__init__()
        # Define layers
        self.layer1 = nn.Linear(1, 1)
        self.layer2 = nn.Linear(…