This is the whole PyTorch script: https://gist.github.com/ProGamerGov/753b64404547662b9ff3d816a7f88f9f#file-test2-py-L144-L195 8
Specifically I am having trouble trying to translate these functions that were made for Lua’s Torch7 library, into Python’s PyTorch Library: https://github.com/jcjohnson/neural-style/blob/master/neural_style.lua#L449-L564 5
For example, the Lua code uses:
self.gradInput:div(torch.norm(self.gradInput, 1) + 1e-8)
And I translated it into:
self.gradInput.div_(torch.norm(self.gradInput, 1) + 1e-8) # Normalize Gradients
But I can’t get any form of it to work inside the ContentLoss or StyleLoss function with the input variable.
Trying to implement any of the other parts of the Lua ContentLoss and StyleLoss functions, also seems to result in the same errors:
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation
I am using the nn.Module for the ContentLoss and StyleLoss functions.