taki0112 / MUNIT-Tensorflow

Simple Tensorflow implementation of "Multimodal Unsupervised Image-to-Image Translation" (ECCV 2018)
MIT License
300 stars 90 forks source link

error in adaptive instance normalization in residual blocks of generator (decoder) ? #12

Open prashnani opened 5 years ago

prashnani commented 5 years ago

Hi, thanks for this Tensorflow implementation!

I was wondering if there is an error in the way adaptive instance normalization is performed in the generator (line 135 in MUNIT.py)?

In the original code by the authors, it seems that they compute mu and sigma for each of the layers of residual blocks of decoder (see assign_adain_params - line 130 in networks.py ). But in your code, it seems like mu and sigma are the same across all of the residual blocks. Could you please clarify?

taki0112 commented 5 years ago

I may not be able to understand your question because I am not good at English.

To answer your question, adain_params is gamma and beta values obtained from MLP. (The author code is mean, std, but the article is written as gamma, beta.)

Use adain_params for the residual block value using AdaptiveInstanceNorm2d in weight, bias

At this time, gamma and beta are not different for each layer. Gamma, beta with the same value obtained from the MLP.

If you do not understand, you can ask me again, I'm fine.

prashnani commented 5 years ago

Thanks for your prompt reply!

Your code has same gamma and beta for each of the 'adaptive_resblock' of the generator.

The original author's code has different gamma and beta for each resblock of the generator.

I was just thinking about the reason behind this difference?

taki0112 commented 5 years ago

I think original author's code has not different gamma, beta.. SAME !

Because assign_adain_params takes gamma and beta from the adain_params whose values are fixed while for the for statement.

prashnani commented 5 years ago

Thanks for your reply! Perhaps I am missing something...here is how I understood it:

In the original author code, the num_adain_params returned by get_num_adain_params function is 4096. That is, there are total 4096 parameters for adaIN operation.

These 4096 parameters in the original author code represent the total number of gamma and beta values of each of the 256 feature maps of 4 residual blocks of the decoder. That is, 4096 = 256 (number of feature maps) 4 (number of residual blocks) 2 (number of conv layers per residual block) * 2 (gamma and beta). These 4096 entries are then assigned to their respective residual block by assign_adain_params function.

In your current code, the number of adaIN parameters are 256 for gamma + 256 for beta (total 512 adain_params).

So I was a bit confused by this difference (512 vs 4096 adaIN parameters). Perhaps 512 is the intended choice of your implementation.