Yes, I am trying to use criterion(output_logits, labels) multiple times to compute g_loss and d_loss. I checked the stop_gradient() in Tensorflow, and try to mimic this operation with detach() in Pytorch. But, if I use detach(), the error would be " variables have no grad". If I don’t use detach(), the error would be “one of the variables needed has been modified by an inplace operation”.
Since you mention the stable gradients, how can I make use of criterion(output_logits, labels) multiple times in Pytorch? I want to use this loss to update G (forward) once, D once, and G (backward) once.