UnsupervisedDeepLearning-Pytorch icon indicating copy to clipboard operation
UnsupervisedDeepLearning-Pytorch copied to clipboard

Possible bug in the code

Open abdulfatir opened this issue 5 years ago • 3 comments

https://github.com/eelxpeng/UnsupervisedDeepLearning-Pytorch/blob/6ea7b7151ae62bf0130b56cc023f2be068aa87f0/udlp/clustering/vade.py#L119

Hi! In this line, why did you replace - (minus) with + at the end?

abdulfatir avatar Apr 07 '19 10:04 abdulfatir

Note that it is -torch.sum(first_term + second_term). I enclose the two terms inside the sum with a negative sign on the front. In math, it should be -log(1/2*pi*sigma^2) - (x-mu)^2/sigma^2.

eelxpeng avatar Apr 08 '19 03:04 eelxpeng

Thanks for the clarification. Didn't notice the parentheses.

abdulfatir avatar Apr 08 '19 05:04 abdulfatir

Hi, How about this? why are you adding pi? qentropy = -0.5*torch.sum(1+z_log_var+math.log(2*math.pi), 1)

I think it is a wrong naming for logpzc variable. Better be KL divergence p_z_c and p_z_x
,and qentropy is included. Also in the loss function, you are only considering binary cross-entropy case in the loss function.

OmranKaddah avatar Jan 07 '20 00:01 OmranKaddah