cmGAN icon indicating copy to clipboard operation
cmGAN copied to clipboard

About the Generator and Discriminatror

Open Fly2flies opened this issue 5 years ago • 2 comments

Hello, I'm a fresh man for the pytorch and GAN. Thanks for you to share such a good implementation. But I'm confused about your training procesure about the G & D. To my best knownledge, the D should try to identify different modalities, while the G do oppsite. Meanwhile, they should be trained respectively and alternately. But as your code:

if epoch%K:
            loss_total = loss_G - gamma*loss_D
        else:
            loss_total = nu*(gamma*loss_D - loss_G)

        loss_total.backward()
        optimizer.step()

The G and D are trained simultaneously, which casued the loss of D become very high while G is being trained, and then the training of G become unstable because of the big loss of D when it's D's turn. When I try to apply the framework to other work, the loss become Nan quickly. So the training process cannot continue.Is there something wrong with my idea, or the codes. Another confusion is that adding the L2 regularization is a neccesary for avoiding overfitting? Looking forward your reply.

Thanks.

Fly2flies avatar Dec 08 '19 10:12 Fly2flies

@EternallyTruth From my personal experience, there is something wrong with the code, and could not converge even after the bugs fixed. Good luck.

prismformore avatar Dec 18 '19 02:12 prismformore

Hello, I'm a fresh man for the pytorch and GAN. Thanks for you to share such a good implementation. But I'm confused about your training procesure about the G & D. To my best knownledge, the D should try to identify different modalities, while the G do oppsite. Meanwhile, they should be trained respectively and alternately. But as your code:

if epoch%K:
            loss_total = loss_G - gamma*loss_D
        else:
            loss_total = nu*(gamma*loss_D - loss_G)

        loss_total.backward()
        optimizer.step()

The G and D are trained simultaneously, which casued the loss of D become very high while G is being trained, and then the training of G become unstable because of the big loss of D when it's D's turn. When I try to apply the framework to other work, the loss become Nan quickly. So the training process cannot continue.Is there something wrong with my idea, or the codes. Another confusion is that adding the L2 regularization is a neccesary for avoiding overfitting? Looking forward your reply.

Thanks.

Hello,have you solved the issue?

jiangyanjavawin avatar Jul 15 '20 13:07 jiangyanjavawin