karpathy / pytorch-normalizing-flows

Normalizing flows in PyTorch. Current intended use is education not production.
844 stars 98 forks source link

Fixed bug with invertibility of AffineHalfFlow #1

Open TrentBrick opened 4 years ago

TrentBrick commented 4 years ago

I realized that the concatenation operation for the AffineHalfFlow is not correct given the even odd masking that occurs. I have implemented a simple fix for this.

janosh commented 4 years ago

Or you could do x0, x1 = x.chunk(2, dim=1) and leave z = torch.cat([z0, z1], dim=1) as is. See the note on cats inverse operation here.

XuebinZhaoZXB commented 4 years ago

I realized that the concatenation operation for the AffineHalfFlow is not correct given the even odd masking that occurs. I have implemented a simple fix for this.

Can we treat this even odd thing as a permutation matrix operation to the original input vector x, and the |log_det| of this operation is 0, then this would not be a bug here (For my own problem, I found the result of this is better than simply: x0, x1 = x.chunk(2, dim = 1) and then using z = torch.cat([z0, z1], dim = 1). Any other got the similar result here?