Palash_Shah:

criterion = DiceLoss()


I think the issue can only be related to definition of DiceLoss here. Can you share it? I think somehow, a tensor is being detached from graph.



 Palash_Shah:

also if I do: loss = Variable(loss, requires_grad = True) it does run but


Yes, as I have mentioned before, if you are getting an error regarding computational graph, suppressing it will not solve the issue as the gradients are not valid which usually end up constant loss or fluctions in it.