pytorch nn.Sequential(*list) TypeError: list is not a Module subclass
when I use pytorch to train a model, I tried to print the whole net structure

so I packed all the layers in a list
then I use nn.Sequential(*list)

but it doesn't work, and the TypeError: list is not a Module subclass

Please provide the list of layers that you have created, are you sure you haven' done any error in that. Try checking if your list is actually [] and not [[..]]. The other thing that I noticed is that you have list as a variable name, which isn't a good idea - list is a Python keyword. 

I tried writing a sample code of unpacking a list and it works fine for me.

import torch
import torch.nn as nn                                                                           net = nn.Sequential(nn.Linear(2, 2), nn.Linear(2, 2))                                           
layers = [nn.Linear(2, 2), nn.Linear(2, 2)]                                                  
net = nn.Sequential(*layers)
print(net)


This ran without any error, and the result was:

Sequential(
  (0): Linear(in_features=2, out_features=2, bias=True)
  (1): Linear(in_features=2, out_features=2, bias=True)
)


Hope this helps. :)
