jwyang / lr-gan.pytorch

Pytorch code for our ICLR 2017 paper "Layered-Recursive GAN for image generation"
151 stars 32 forks source link

Question on conditional image generation #6

Open tackgeun opened 6 years ago

tackgeun commented 6 years ago

With the help of your advice, I reproduced the main part of the paper and succeed in training your model to ImageNet with specific classes, minibus, dog.

Now, I try to reproduce 6.8 conditional image generation in the paper to use this architecture for unsupervised/weakly-supervised object segmentation. But I had a hard time to find a trainable setup. Can you share a setting in the experiment?

[Encoder architecture]

[Optimization method]

Thanks.

jwyang commented 6 years ago

Hi, @tackgeun ,

glad to know you have successfully get the results as the paper!

Regarding the conditional image generation,

[Encoder architecture]

yes, I also used the same architecture as the discriminator, except that the output layer is a fc layer.

yes, exactly, but I put a batch normalization layer before the last fc layer.

yeah, that's what I did.

yes, that's what I did.

[Optimization method]

In my experiments, I used reconstruction loss (with weight 1e-3) plus the adversarial loss for training the generator, and the same loss as original GAN for training the discriminator.

Also, please remember to regularize the transformation parameters. The rotation should be minor or even void during training.

Hope these are helpful.

tackgeun commented 6 years ago

With your help, my code starts to generate an image. But reconstructed images are blurry compared to the paper. But I'm confusing that the encoder architecture and the way of updating generator weight.

Architecture

Do you mean that the last part of encoder network like this?

Optimization

The encoder is embedded within generator class. So I compute gradient for

  1. adversarial loss for generator(random noise)
  2. weighted reconstruction loss(encoded image).

Then, those gradients are accumulated to compute the gradient of the sum of all losses. Following the above description, the generator's weight is updated w.r.t (1) + (2) and the encoder's weight is updated w.r.t only (2).

Thank you.

jwyang commented 6 years ago

Hi, @tackgeun

With your help, my code starts to generate an image. But reconstructed images are blurry compared to the paper. But I'm confusing that the encoder architecture and the way of updating generator weight.

Architecture

Do you mean that the last part of encoder network like this?

I used Tanh() as the last layer for the encoder, to make the output in a reasonable range.

Optimization

The encoder is embedded within generator class. So I compute gradient for

  1. adversarial loss for generator(random noise)
  2. weighted reconstruction loss(encoded image).

Then, those gradients are accumulated to compute the gradient of the sum of all losses. Following the above description, the generator's weight is updated w.r.t (1) + (2) and the encoder's weight is updated w.r.t only (2).

Actually, I update both the generator and the encoder with (1) and (2). And the weight for reconstruction loss is much lower, 1e-3 to 1e-2.

Thank you.

tackgeun commented 6 years ago

@Hi, I just have returned from the ICCV... and my implementation still has problems.

Thank you for your advice.