Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training vgnet generator loss keeps increasing #19

Open
ssinha89 opened this issue Oct 11, 2019 · 7 comments
Open

Training vgnet generator loss keeps increasing #19

ssinha89 opened this issue Oct 11, 2019 · 7 comments

Comments

@ssinha89
Copy link

I am training VGNET on GRID dataset using the code in vgnet.py. The input to the network are the dlib landmarks after procrustes alignment, and the ground-truth image labels are the cropped face images after warping to the neutral head pose. While the discriminator losses for real and fake images keep reducing to a very low value, the generator loss keeps increasing throughout training. The quality of the generated images keeps decreasing after a few epochs, i.e, the GAN training does not converge. Could you please suggest what could be the issue.
discriminator loss fake
discriminator loss real
generator loss

@lelechen63
Copy link
Owner

I am training VGNET on GRID dataset using the code in vgnet.py. The input to the network are the dlib landmarks after procrustes alignment, and the ground-truth image labels are the cropped face images after warping to the neutral head pose. While the discriminator losses for real and fake images keep reducing to a very low value, the generator loss keeps increasing throughout training. The quality of the generated images keeps decreasing after a few epochs, i.e, the GAN training does not converge. Could you please suggest what could be the issue.
discriminator loss fake
discriminator loss real
generator loss
Are you using pytorch 0.4? Also, you need to preprocess the landmark to -0.2 to 0.2 I think. Meanwhile, you need to have pixel loss to stable the training.

@ssinha89
Copy link
Author

I have done the preprocessing (landmark -0.2 to 0.2 then multiplied by 5), using pytorch 0.4 and using the same combination of loss functions as in vgnet.py. After a few iterations the discriminator loss goes down rapidly due to which the gradient in the generator disappears, and the attention mask learnt by the generator also becomes zero. Have you observed this kind of phenomenon during training, if so how did you overcome the problem.

@ssinha89
Copy link
Author

ssinha89 commented Oct 25, 2019

I am still facing this issue of GAN convergence while training VGNET with ground truth 2D landmarks(scaled) and face images(cropped and warped). The generator GAN loss keeps increasing during the training process, even with the additional supervised L1 loss on pixel intensities. Could you please mention if you faced such a problem during the training.

@lelechen63
Copy link
Owner

lelechen63 commented Oct 26, 2019

I am still facing this issue of GAN convergence while training VGNET with ground truth 2D landmarks(scaled) and face images(cropped and warped). The generator GAN loss keeps increasing during the training process, even with the additional supervised L1 loss on pixel intensities. Could you please mention if you faced such a problem during the training.

I didn't encounter this problem. I tested this training code when it was released. My suggestion is that you can first remove other loss functions and only use L1 loss to supervise the network. It should also generate reasonable results. Then you can add the GAN loss to see it is loss problem or it is network problem.

@ssinha89
Copy link
Author

ssinha89 commented Oct 28, 2019

Thanks for the suggestion. I trained the network with only the L1 loss on GRID dataset. As you said the results are reasonably good, however there is blur in the texture near the mouth region. On adding the GAN loss along the with L1 loss, there is the same problem which I described earlier, i.e, the discriminator loss keeps decreasing and the generator loss keeps increasing. I tried changing the relative weightage of the loss terms, (L1 loss 10 times or 100 times the GAN loss), with not much improvement. While training the GAN, did you use the same learning rate and Adam optimization parameters as given in the vgnet.py (lr = 0.0002, beta1 = 0.5, beta2=0.999)?

@lelechen63
Copy link
Owner

Thanks for the suggestion. I trained the network with only the L1 loss on GRID dataset. As you said the results are reasonably good, however there is blur in the texture near the mouth region. On adding the GAN loss along the with L1 loss, there is the same problem which I described earlier, i.e, the discriminator loss keeps decreasing and the generator loss keeps increasing. I tried changing the relative weightage of the loss terms, (L1 loss 10 times or 100 times the GAN loss), with not much improvement. While training the GAN, did you use the same learning rate and Adam optimization parameters as given in the vgnet.py (lr = 0.0002, beta1 = 0.5, beta2=0.999)?

Yes, the optimation is the same one. Can you change the gan loss to LSGAN. Basically, remove the sigmoid layer and change the discriminator loss with mseloss ranther than bceloss. My new experiments show that lsgan is more stable than vanila gan.

@gogozhaoya
Copy link

I got similar results as you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants