Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inplace Operations Error #4

Open
re-young opened this issue Jan 3, 2019 · 3 comments
Open

Inplace Operations Error #4

re-young opened this issue Jan 3, 2019 · 3 comments

Comments

@re-young
Copy link

re-young commented Jan 3, 2019

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!

@AtriSaxena
Copy link

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.

@dalmiaman
Copy link

dalmiaman commented Jan 30, 2019

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

@AlexSunNik
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants