ptrblck:

You should use nn.ModuleList and add the linear layers to it instead of using a Python list, as the latter won’t properly register the modules (as seen in the print statement).
Besides that, your code should be working fine. 


This worked perfectly! Thank you!
For anyone interested this is the final code:
class Classifier_OneHot_list(nn.Module):
 
    def __init__(self,input_size,hidden_size,output_size):
        super().__init__()

        self.nC=output_size 
        self.ic1 = nn.Linear(input_size, hidden_size) 

        self.linears = nn.ModuleList([nn.Linear(hidden_size, 3) for i in range(self.nC)])

    def forward(self, x):

        hlo=F.relu(self.ic1(x))
        
        self.TensorList=[self.linears[i](hlo) for i in range(self.nC)]
        
        out=torch.stack(tuple(self.TensorList),axis=-1)

        return out