Thank you very much for your reply! I was forced to use p = torch.autograd.Variable(tPred[0].data, requires_grad=True) due to an error one of the variables needed for gradient computation has been modified by an inplace operation… how i can use yPred with clices in my custom loss as torch.log(tPred[0]) + torch.sum(torch.abs(tPred[1:] - tTrue[1:])) ?