RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [3, 1]], which is output 0 of TanhBackward, is at version 1; expected version 0 instead

Inplace operations are disallowed if the tensor is needed to calculate the gradients during the backward pass as e.g. given in this example.

1 Like