Hello, I’m trying to create such a Network:
class Net(torch.nn.Module):
def __init__(self):
super(Net, self).__init__()
self.linears = [torch.nn.Linear(5, 10)] * 10
self.special_linear = torch.nn.Linear(100, 500)
model = Net()
Because I need lots of linears so I just put them into a list at once, but it seems not be a submodule member of Net:
print(list(model.modules()))
/home/hdl2/anaconda3/bin/python /home/hdl2/Desktop/xxx/playground.py
[Net (
(special_linear): Linear (100 -> 500)
), Linear (100 -> 500)]
Process finished with exit code 0
So I’d like to know if there any way to register those linears to be submodule member of Net? Thanks in advance.