RuntimeError:Output 0 of UnbindBackward0 is a view and is being modified inplace.

想复现Adversarial Deepfakes: Evaluating Vulnerability of Deepfake Detectors to Adversarial Examples(https://adversarialdeepfakes.github.io/) 这篇文章的代码,本来第一个detect_from_video.py检测已经运行出来了,在运行攻击attack.py的时候爆红了,然后发现其他的代码包括已经运行成功过的也是同样的理由爆红了,

RuntimeError: Output 0 of UnbindBackward0 is a view and is being modified inplace. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.

看到有帖子说要改for循环,可是试了一下好像不行,也可能是我没有改对,www,请问有big old可以帮忙看看嘛

img

感谢感谢,好人一生不爆红无error

这个错误是因为代码中使用了 inplace 操作,导致输出的 tensor 无法被修改。建议尝试将 inplace 操作改为 out-of-place 操作,即在操作前先复制一份 tensor,然后对其进行操作。你可以尝试修改代码中的 inplace 操作,或者找到相关的库或函数来实现 out-of-place 操作。另外,也可以确认一下你使用的 PyTorch 版本是否与代码中使用的版本一致,如果不一致也可能导致这个错误。