Hi. I am also facing a similar kind of scenario. I am trying to implement a simple GAN with generator and discriminator being respective classes.
# Generator Neural Network Model (1 hidden layer)
class GNet(nn.Module):

    def __init__(self, input_size, hidden_size, image_size):
        super(GNet, self).__init__()

        self.model = nn.Sequential(
            nn.Linear(input_size, hidden_size),
            nn.ReLU(),
            nn.Linear(hidden_size, image_size),
        )
    def forward(self, x):

        return self.model(x)

# Discriminator Neural Network Model (2 hidden layer)

class DNet(nn.Module):
    def __init__(self, image_size, hidden_size):

        super(DNet, self).__init__()
        self.model = nn.Sequential(
            nn.Linear(image_size, hidden_size),
            nn.ReLU(),
            nn.Linear(hidden_size, hidden_size),
            nn.ReLU(),
            nn.Linear(hidden_size, num_classes),
        )

    def forward(self, x):
      return self.model(x)


G = GNet(input_size, hidden_size, image_size)
D = DNet(image_size, hidden_size)
G_params = G.parameters()
D_params = D.parameters()
G_solver = optim.Adam(G_params, lr=1e-3)
D_solver = optim.Adam(D_params, lr=1e-3)

I am getting the error message in the line of G_solver:
ValueError: optimizer got an empty parameter list

Why I am I not getting the parameter list even if I am calling D.parameters()