Hi,
When using the autograd engine you must never use .data.
.data should never be used ! It is a legacy api that allows you to perform computation without computing gradients for them. The new api for that is the torch.no_grad() context manager.
I guess removing all the .data from your code and the wrapping into a Variable at the end of your forward will most certainly fix your problem. Note that if you’re using 0.4, you don’t need to call Variable anywhere as all Tensors are Variables now.