Hi @ptrblck, I was hoping you could aid me on another problem. I am currently getting this error RuntimeError: element 0 of variables does not require grad and does not have a grad_fn and I have seen your previous solutions to this. The error occurs when the .backward() func is called, and I believe it is due to the loss functions and them possibly having the required_grad = False?
Here is my optimize_parameter and forward() func:

def forward(self):
    if self.opt.stage == 'full' or self.opt.stage == 'instance':

        (_, self.fake_B_reg) = self.netG(self.real_A, self.hint_B, self.mask_B)
    else:
        print('Error! Wrong stage selection!')
        exit()



def optimize_parameters(self, optimize):
    self.forward()

    optimize.zero_grad()

    if self.opt.stage == 'full' or self.opt.stage == 'instance':

        self.loss_L1 = torch.mean(self.criterionL1(self.fake_B_reg.type(torch.cuda.FloatTensor),

                                                    self.real_B.type(torch.cuda.FloatTensor)))

        self.loss_G = 10 * torch.mean(self.criterionL1(self.fake_B_reg.type(torch.cuda.FloatTensor),

                                                    self.real_B.type(torch.cuda.FloatTensor)))

else:
        print('Error! Wrong stage selection!')

        exit()

    self.loss_G.backward()

    optimize.step()


Any help is much appreciated