Solved by Chirath_Pansilu in post #2 
              
              
                I think it will be easier if you use torch.nn.Sequential container. 
You can pass in your defined layer list to it and there will be no problem.