The goal is to train this GAN based on multiple loss functions, I keep getting this error about inplace operations. Here is the problem section:

image749×572 21 KB

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_2885/1167578605.py in <module>
     28 
     29         opt_gen.zero_grad()
---> 30         lossG.backward()
     31         opt_gen.step()
     32 

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 784]], which is output 0 of UnsqueezeBackward0, is at version 33; expected version 32 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

If any additional information is needed, please let me know.  Thanks!