Open Schwartz-Zha opened 3 years ago
As far as I am concerned, the GLOW (or normalization flow) model try to max likelihood of training data, which means max the log probability (the var objective
in my code) and thus means min the -objective
.
logdet += float(-np.log(256.) * pixels)
About this line, I cannot recall the details. It is supposed to handle some extra multiplication factor out of det()
.
-np.log(256.)
is used to approx intergration for discrete pixel values.pixels
handles the (width, height) dimension of input.Well, from my reading in another paper "Generative Flow via n * n Convolution: Thanh-Dat Truong et al.". The data is added with a random uniform noise, which is the discretization level of the data, making the input continuous.
Could you get some hint? (I'm still confused...)
float(-np.log(256.) * pixels)
discretized level is a number denote the range of 8 bit pixel (2^8=256). So, glow paper mentioned c=-M x log a
, where a=256
in Eq(2), while M is the number of total pixels in your image (i.e. 32 32 image, `M=3232`).
@chaiyujin i wonder why the objectives will need to divided by float(np.log(2.) * pixels
? what is that means ?
This normal_flow() function is the core forward propagation part of Glow. "nll" here is just passed to this line in trainer.py
And Glow.loss_generative is just a static function (just take the mean)
So basically nll is just the loss. Then move our attention to "objective", from my understanding of each nn.Module in this project, it's the sum of log determinant of each nn.Module .
Then let's take a broad view of the whole model. We start from z (input x added with some noise), go through many transformations So, the final output
Suppose p() represents the likelihood of each instance, and x represents a real image from the dataset, the object of this generative model should be The right hand side is always smaller than the left side, so the objective is just to enlarge the rhs. So the objective function of optimization is
But the computation of "nll" shows that it's actually Is this really correct?
And by the way, what's the point of this line?