RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 1024, 4, 4]] i s at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autogra d.set_detect_anomaly(True).
将
G_loss.backward()
替换为
loss1 = G_loss.detach_().requires_grad_(True)
loss1.backward()