Error:
runtimeerror: one of the variables needed for gradient computation has been modified by an inplace operation
Analysis: the new version of pytorch integrates variable and tensor into one tensor, and the inplace operation can be used for variable before, but errors will occur when using tensor
Check whether there is the following expression
x += res #error
Change to
x = x + res
No error is reported