google / compare_gan

Compare GAN code.
Apache License 2.0
1.82k stars 317 forks source link

Can't create a module from a checkpoint path #31

Closed anth2o closed 5 years ago

anth2o commented 5 years ago

First of all, thanks for the code which is very complete and well documented. Nonetheless, I have an issue to use the modules created in the evaluation to generate samples.

I trained a BigGAN on the Cifar10 dataset, with the same config file as the one provided for BigGAN on ImageNet. I visualized the generated images on Tensorboard, and the GAN seemed to be learning correctly. Thus, I evaluated it to check the metrics and create the modules corresponding to different checkpoints.

The problem is that, once I loaded a module from the file system, it was generating images only composed of 0s and 1s. I'm not able to generate similar pictures to the ones generated during training and displayed on Tensorboard.

Do you have an idea of how to fix this issue ?

Thanks in advance

Marvin182 commented 5 years ago

Thanks :)

If you use BigGAN the batch statistics (the generator uses batch normalization) are not kept during training (as often done). Instead the statistics are computed by doing forward passes through the TFHub module (see _update_bn_accumulators() in eval_gan_lib.py). The eval will do this for you and write the statistics to a checkpoint (see eval_gan_lib.py line 162)). If you later want to use the TFHub module you have to first load the module and then load the checkpoint. Do you do this?

anth2o commented 5 years ago

I wasn't using that, but now it seems to work. Thanks !