Solved by ptrblck in post #2 
              
              
                You would have to initialize W as an nn.Parameter or set it requires_grad attribute to True in the creation. 
Also don’t wrap outputs in new tensors, as this will detach the computation graph. 
This code snippet should work: 
x=[torch.tensor([0,1]),torch.tensor([[2,3],[0,1]]),torch.tensor([4,5])]
W=…