Lasagne / Recipes

Lasagne recipes: examples, IPython notebooks, ...
MIT License
914 stars 419 forks source link

Variational Autoencoder: cannot understand why there is a '2' coefficient for log sigma #90

Open stablum opened 7 years ago

stablum commented 7 years ago

Hi,

this is the line 190 of variational_autoencoder.py:

- 0.5 * T.sqr(tgt - mu) / T.exp(2 * ls))

where does that 2 coefficient for the log sigma come from? I did the derivations myself and I could not find it. This other implementation: https://github.com/y0ast/Variational-Autoencoder/blob/master/VAE.py does not include that multiplier. Any explanation? Is it a bug?

f0k commented 7 years ago

@tencia, do you still know what you did there?

tencia commented 7 years ago

No, unfortunately I don't remember where that term came from, sorry.

loek-tonnaer commented 7 years ago

Likely it's the square in sigma^2 ;) when dealing with log_sigma it "comes down", i.e. exp(2*log(sigma)) = exp(log(sigma^2)) = sigma^2