I’m training a GAN
the traininng code is here
            while images is not None:
                outputs=self.model['G'](images)
                self.model['D'].freeze(requires_grad=True)
                po=self.model['D'](outputs.detach())
                pg=self.model['D'](images)
                loss1=self.criteron['adv'](po,False)
                loss2=self.criteron['adv'](pg,True)



But I got this error message which makes me confused.
one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [256]] is at version 4; expected version 3 instead.
I tried several times,and I removed all inplace tag in RELU.
The code works fine while only loss1 is calculated and backward, or loss2 is calculated and backward.But It reported this error when I write them both into the training code.
And I found that I put gt and output both into the discriminator, then loss1 and loss2 is ok to be calculated.The critical code makes loss1 unable to backward is this line
pg=self.model['D'](images)

Removing this,my loss1 works fine.
But my dis network just conv and maxpool the image,and there is no in-place op.
I also replace this line:
pg=self.model['D'](images.clone().detach())

it still can’t work.
what’s wrong?