You could either use nn.ModuleList or nn.Sequential to store the layers. Python lists and dicts aren’t the right ones for storing torch modules.

  
    
    
    The difference in usage between nn.ModuleList and python list 
  
  
    I can’t figure out what the purpose of nn.ModuleList is because as far as I know, list can be used in most scenarios I come up with. 
For example, for the newtork structure below, 
	def __init__(self):
		super(MyNN, self).__init__()
		fcs = [nn.Sequential(
				 nn.Linear(fc_input_size, fc_hidden_size),
				 nn.ReLU(),
				 nn.Linear(fc_hidden_size,num_classes)
		) for fc_hidden_size in fc_hidden_sizes]
		#self.network = nn.ModuleList(fcs)
		self.network = fcs

I don’t see the difference between …