Solved by anantguptadbl in post #5 
              
              
                example formula 
[image] 
x = torch.Tensor([1,2,3])
W = torch.nn.Parameter(torch.Tensor([[0.4],[0.5],[-0.6]]), requires_grad=True)
c = torch.matmul(x, W)
d = torch.nn.functional.sigmoid(c)
loss = torch.tensor([1.]) - d
loss.backward()
W.grad

# Results
tensor([[-0.2403],
        [-0.4805],
        […