djl icon indicating copy to clipboard operation
djl copied to clipboard

[W TensorBody.h:491] Warning: The .grad attribute of a Tensor that is not a leaf Tensor is being accessed.

Open havetobe opened this issue 8 months ago • 1 comments

[W TensorBody.h:491] Warning: The .grad attribute of a Tensor that is not a leaf Tensor is being accessed. Its .grad attribute won't be populated during autograd.backward(). If you indeed want the .grad field to be populated for a non-leaf Tensor, use .retain_grad() on the non-leaf Tensor. If you access the non-leaf Tensor by mistake, make sure you access the leaf Tensor instead. See github.com/pytorch/pytorch/pull/30531 for more informations. (function grad)

I found the same error in https://github.com/deepjavalibrary/djl/issues/2133, but there's no specific solution for it. My code does not have any errors; the only solution now is to suppress the output of these warnings, but this does not fundamentally solve the problem, it merely conceals the warnings.

havetobe avatar Mar 14 '25 03:03 havetobe