1Konny / FactorVAE

Pytorch implementation of FactorVAE proposed in Disentangling by Factorising(http://arxiv.org/abs/1802.05983)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some questions about some codes in the implementation

HelenMao opened this issue · comments

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!

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

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.

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

No, I didn't.

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 D_z should be ones and that for D_z_pperm should be zeros.

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.