Closed gitlabspy closed 4 years ago
You can simply use the flag, 「conditional=False」 in all factor layer https://github.com/MokkeMeguru/TFGENZOO/blob/master/TFGENZOO/flows/factor_out.py#L40-L60
if self.conditional:
mean, logsd = self.split2d_prior(z1)
ll = gaussianize.gaussian_likelihood(mean, logsd, z2)
else:
ll = gaussianize.gaussian_likelihood(
tf.zeros(tf.shape(z2)), tf.zeros(tf.shape(z2)), z2
)
This shows gaussian distribution.
Notice and Warning: Flow-based Model's gaussian distribution is not as same as Multivariational Normal Ditribution []H, W, C], but gaussian distribution x [H, W, C] times.
(I added label because my searching problem... sry)
No problem 😃, it is a question. I still have two question tho.
The loss function here is to maximize log_likelihood of z produced by input x, instead of x's log_likelihood, right? Would it produce the exact same outcome compared with calculating the log_likelihood of x like the way in tfp
using transform_dist.log_prob(x)
does ?
You were saying "gaussian distribution x [H, W, C] times.", does it mean a couple of [H,W,C]-shape-like independent gaussian?
2.'s reference https://github.com/tensorflow/probability/issues/720
Wow, I almost forgot it can be changed into z with change of variable formule. The way you implement flow is very similar to those paper source codes(glow flowpp etc.), which kinda easy for me to transform some of their codes into tf2 with your lib. I tried TFP tho, it's kinda hard for me understand the way they define shape, like event_shape, batch_shape... 😂
Thx for your explanation! It helps me a lot!
TFP has some useful function such as Inv1x1Conv's log det jacobian function.
We only calculate "log determinant |W| " because they estimate H x W by the "event_shape"
We should calculate "H x W x log determinant |W|" ... However, we can write a code with its formula. (I like this style because we prevent missmatch implementation)
I noticed you calculate the z's log_prob and add it to log_likelihood which is provided by factor_out, I don't understand this process. You bounded the log_likelihood calculation with factor_out layer, right? What if we don't factor_out , we just assume that z is normal gaussian, then how do we train? Hopefully you can provide me some guides! Thanks!!!!