wilsonmr / anvil

Repository containing code related to flow based generative model
https://wilsonmr.github.io/anvil/
GNU General Public License v3.0
0 stars 2 forks source link

New coupling layer: quadratic spline #49

Closed jmarshrossney closed 4 years ago

jmarshrossney commented 4 years ago

Extension of #48 which uses a coupling transformation that is quadratic in the input data. Also introduced in https://arxiv.org/pdf/1808.03856.pdf.

The bin widths are part of the neural net output (rather than being a global constant), which means the bisection search has to be done on a per-unit basis. To avoiding looping, which is very slow, the x_b tensor is temporarily reshaped into a tensor of dimensions (n_batch * size_half, 1) so that the sorting can be done with one call to searchsorted. It does make me uneasy to mix the batch and lattice dimensions, but it's just for one step and it's a lot faster than looping!