withtimesgo1115 / gradCAM-YOLOv3-pytorch

This repository contains key scripts for implementing gradient CAM algorithm for YOLO v3 model. The codes has been tested on pytorch 1.7.1.
MIT License
24 stars 6 forks source link

problem sovled #5

Open noobgrow opened 2 years ago

noobgrow commented 2 years ago

在backward()计算时报错, one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [3, 1]], which is output 0 of SliceBackward, is at version 2; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True). 认为应该是nms过程中求导的问题,您能否提供使用的代码学习一下?万分感谢!!!

withtimesgo1115 commented 2 years ago

Hi, you can refer to the closed issue #1

noobgrow commented 2 years ago

@withtimesgo1115 sir, THANKS for your reply! I refer to the issue #1 ,then download the WZMIAOMIAO's code of yolo, and add the gradCAM code in it. The error above occurs again.

I solve this error as follows: I found SliceBackward occur in NMS code, so I tried to define intermediate variables to avoid variable value re-assignment. Then I can get the leaf Tensor(Input image)'s gradient.

syusukeljq commented 2 years ago

您好,能看一下您修改后的代码吗?十分感谢! @noobgrow