When backward, if you only update part network. For example, when training GAN, updating only netD and not updating netG, you should write like this:
fake = netG(noise)
out_ = netD(fake.detach())
loss = …
As for .data, from data-type Variable, get data through '.data '.