toandaominh1997 / EfficientDet.Pytorch

Implementation EfficientDet: Scalable and Efficient Object Detection in PyTorch
MIT License
1.44k stars 305 forks source link

Gradient computation error #161

Open siaavashZ opened 2 years ago

siaavashZ commented 2 years ago

Hello When I run the train.py module, I get this error:

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [3, 3]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!

mengfei25 commented 2 years ago

met this issue too, is there any solutions?

siaavashZ commented 2 years ago

Hello, I solved this In the models directory, you should change lines 178 and 180 of the bifpn.py module.

Just replace this

w1 /= torch.sum(w1, dim=0) + self.eps  # normalize

w2 /= torch.sum(w2, dim=0) + self.eps  # normalize

to this:

w1 = w1/(torch.sum(w1, dim=0) + self.eps)  # normalize

w2 = w2/(torch.sum(w2, dim=0) + self.eps)  # normalize