Don’t use the .data attribute, as it’s deprecated and could yield unwanted side effects since Autograd isn’t able to track these tensors.
Also, Variables are deprecated since PyTorch 0.4, so you can use tensors now.
Note that re-wrapping tensors into a new tensor (or Variable in your case) will also detach these tensors from the computation graph, so avoid this in case you want to keep the computation graph of the previous operations.