Below is a sample code of something I am trying to implement :
import torch
import torch.nn as nn
class tmpNw(nn.Module):
def __init__(self):
    super(tmpNw, self).__init__()
    self.linear = []
    self.linear.append(nn.Linear(2, 3))
    self.linear.append(nn.Linear(3, 3))

def forward(self, x):
    x = self.linear[0](x)
    x = self.linear[1](x)
    return x

nw = tmpNw()
print list(nw.parameters())
optimizer = torch.optim.Adam(nw.parameters(), lr=1e-3)
It returns empty parameter, so I am unable to create the optimizer object.