Solved by ptrblck in post #2 
              
              
                Your model works fine using this code: 
class G_networkDef(nn.Module):
    def __init__(self, lh1, lh2, lh3, lh4, lh5):
        super(G_networkDef, self).__init__()
        self.fc1 = nn.Linear(lh1, lh2)
        self.fc2 = nn.Linear(lh2, lh3)
        self.fc3 = nn.Linear(lh3, lh4)
        self.fc4 =…