1Konny / FactorVAE

Pytorch implementation of FactorVAE proposed in Disentangling by Factorising(http://arxiv.org/abs/1802.05983)
MIT License
262 stars 48 forks source link

Some questions about some codes in the implementation #10

Closed HelenMao closed 5 years ago

HelenMao commented 5 years ago

Hi, thanks for your great implementation of Factor-VAE. I want to introduce the total correlation loss in my work so that I read your implementation carefully. However, there are some codes I do not understand. In solver.py line107 vae_tc_loss = (D_z[:, :1] - D_z[:, 1:]).mean() why you use this to compute the tc_loss for VAE and line 119 D_tc_loss = 0.5*(F.cross_entropy(D_z, zeros) + F.cross_entropy(D_z_pperm, ones)) when optimizing the discriminator, why the label of D_z is zeros and D_z_pperm is ones. Looking forward to your response, thanks!

speedcell4 commented 5 years ago

@HelenMao did you figure that out? I get focused on that too

HelenMao commented 5 years ago

Yes, the paper gives some implementation details. E.g. Figure1 said that the label of D_z is zeros and D_z_pperm is ones.

speedcell4 commented 5 years ago

Thank you so much. By the way, did you implement the metric mentioned in Figure 2?

HelenMao commented 5 years ago

No, I didn't.

Natsu6767 commented 5 years ago

Yes, the paper gives some implementation details. E.g. Figure1 said that the label of D_z is zeros and D_z_pperm is ones.

However, I believe that according to Algorithm 2 in the paper, the label for _Dz should be ones and that for _D_zpperm should be zeros.

HelenMao commented 4 years ago

In fact, the codes use F.cross_entropy this function. The second input is target which means the target class. The output of the discriminator is two classes. zero indicates the first class, and one indicates the second class.