Transformers-Tutorials icon indicating copy to clipboard operation
Transformers-Tutorials copied to clipboard

Update bbox coordinates to tensor without gradients

Open russhustle opened this issue 3 years ago • 1 comments

I got this error: RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead. So, I apply x.detach() to coordinates of bounding boxes.

I added one line in the loop for the attention visualization: xmin, ymin, xmax, ymax = map(lambda x: x.detach(), (xmin, ymin, xmax, ymax))

Tensor.detach() is used to detach a tensor from the current computational graph. It returns a new tensor that doesn't require a gradient.

russhustle avatar Sep 04 '22 16:09 russhustle

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB