I have a Generator and two classifiers. I want to train Generator(G) with classifier’s output loss.
I’m not sure classifier’s output loss can reach generator training.
If I train like this, loss_dis can affect G(Generator) ?
G = Generator()
C1 = Classifier()
C2 = Classifier()

self.opt_g = optim.SGD(self.G.parameters(),
                    lr=lr, weight_decay=0.0005,
                    momentum=momentum)
self.opt_c1 = optim.SGD(self.C1.parameters(),
                      lr=lr, weight_decay=0.0005,
                      momentum=momentum)
self.opt_c2 = optim.SGD(self.C2.parameters(),
                     lr=lr, weight_decay=0.0005,
                     momentum=momentum)

feat = G(img)
output_t1 = C1(feat)
output_t2 = C2(feat)
loss_dis = cross_entropy_loss(output_t1, output_t2)
loss_dis.backward()

self.opt_g.step()

opt_g.zero_grad()
opt_c1.zero_grad()
opt_c2.zero_grad()