pytorch-normalizing-flows
pytorch-normalizing-flows copied to clipboard
Potential bug detected for high-dimension real NVP
I found the backflow of real NVP cannot reconstruct the original input data. This is caused by a bug in code when the dimension is more than 2:
https://github.com/karpathy/pytorch-normalizing-flows/blob/b60e119b37be10ce2930ef9fa17e58686aaf2b3d/nflib/flows.py#L108
https://github.com/karpathy/pytorch-normalizing-flows/blob/b60e119b37be10ce2930ef9fa17e58686aaf2b3d/nflib/flows.py#L122
They should be:
x0, x1 = x[:, :self.half_dim], x[:, self.half_dim:] z0, z1 = z[:, :self.half_dim], z[:, self.half_dim:]
See #1.