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

torch backpropagate problem #4

Open
cuge1995 opened this issue May 6, 2021 · 2 comments
Open

torch backpropagate problem #4

cuge1995 opened this issue May 6, 2021 · 2 comments

Comments

@cuge1995
Copy link

cuge1995 commented May 6, 2021

Hey, I'm trying to use torch to reimplement your work. But occurring the backpropagate problem.
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [256]] is at version 5; expected version 4 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

the code is as follows:

logits = self.model(adv_data)
new_logits = self.model(self.encoder(adv_data)))
adv_loss = 0.75*self.adv_func(logits, target).mean() + 0.25*self.adv_func(new_logits, target).mean()

Do you think the code is right?

@ajhamdi
Copy link
Owner

ajhamdi commented Aug 11, 2021

yes, it should be like that. This error happens when the tensor in the Pytorch graph is being modified

@ajhamdi
Copy link
Owner

ajhamdi commented Aug 11, 2021

@cuge1995 could you please direct me to the repo of the PyTorch implementation. I can help with that.

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

2 participants