Solved by ptrblck in post #2 
              
              
                You could create a new custom nn.Module and add it into the nn.Sequential container: 
class ShiftLayer(nn.Module):
    def __init__(self, b):
        super().__init__()
        self.register_buffer('b', b)
        
    def forward(self, x):
        return x + self.b

class Generator(nn.Module):
    …