SSD-variants icon indicating copy to clipboard operation
SSD-variants copied to clipboard

Inplace Operations Error

Open re-young opened this issue 6 years ago • 3 comments

Hey,

I am trying to run this with pytorch 1.0.0 and get the following error

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation

Any suggestions?

Thanks!

re-young avatar Jan 03 '19 21:01 re-young

Hey,

I am also trying to run with pytorch 1.0.0 and getting the same error.

Trying to resolve this. Will let you know if i will find any solution.

Thanks.

AtriSaxena avatar Jan 15 '19 11:01 AtriSaxena

Just solved it. The error is in models/SSD.py The inplace operation happens in the class L2Norm. Replace that with this (courtesy amdegroot/ssd.pytorch):

class L2Norm(nn.Module):
    def __init__(self,n_channels, scale=20):
        super(L2Norm,self).__init__()
        self.weight = nn.Parameter(torch.Tensor(n_channels))
        nn.init.constant_(self.weight, scale)

    def forward(self, x):
        norm = x.pow(2).sum(dim=1, keepdim=True).sqrt()+1e-10
        x = torch.div(x,norm)
        out = self.weight.unsqueeze(0).unsqueeze(2).unsqueeze(3).expand_as(x) * x
        return out

dalmiaman avatar Jan 30 '19 17:01 dalmiaman

Hi guys. Are you able to achieve the same reported accuracy training from scratch using this repo code? Thanks!

AlexSunNik avatar Jan 07 '21 04:01 AlexSunNik