-
Notifications
You must be signed in to change notification settings - Fork 412
Open
Description
I am trying to implement the 1D flow as shown in Flow Models Demos (Official).ipynb. I can't figure out what is self.loc in the MixtureCDFFlow class. Also, what does self.n_components denote?
This is the code
def flow(self, x):
# set up mixture distribution
weights = F.softmax(self.weight_logits, dim=0).unsqueeze(0).repeat(x.shape[0], 1)
mixture_dist = self.mixture_dist(self.loc, self.log_scale.exp())
x_repeat = x.unsqueeze(1).repeat(1, self.n_components)
# z = cdf of x
z = (mixture_dist.cdf(x_repeat) * weights).sum(dim=1)
# log_det = log dz/dx = log pdf(x)
log_det = (mixture_dist.log_prob(x_repeat).exp() * weights).sum(dim=1).log()
return z, log_det
Some help is really appreciated.
Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels