ndeutschmann / zunis

Normalizing flows for neural importance sampling
https://zunis.readthedocs.io
MIT License
33 stars 6 forks source link

Include piecewise-quadratic coupling cells #3

Closed NGoetz closed 4 years ago

NGoetz commented 4 years ago

Piecewise-quadratic coupling transforms following the strategy presented in arXiv:1808.0385 were added, including their inverse. An integration config file was added which, when used as an option when starting the benchmarking example, does perform the integration with piecewise-quadratic coupling cells. The inversion of piecewise-quadratic coupling cells requires solving a quadratic equation and suffers more easily from instabilities. The same safety measures regarding CUDA errors were taken as for the piecewise-linear coupling cells. Apart from this, the inversion does reach a slightly reduced accuracy. For 20000 points being mapped and inverted 5 times, the variance of the with 1 initialized Jacobian is 4.47+-0.09 E-16 for dimension 2 and 3.41 +-0.12 E-16 for dimension 8 for piecewise-linear coupling cells, however 7.48 +- 0.45 E-15 and 5.62 +- 0.83E-14 for piecewise-quadratic coupling cells.

Nevertheless, using the benchmarking examples for the camel, the gaussian and the cosine function, it can be seen that the piecewise-quadratic cells can greatly improve the performance in certain cases. For 10 bins with the camel function, there is a great improvement in low dimensions and small to none in high dimensions. For the Cosine, it is virtually the same quality, and in 10 dimensions with 10 bins even a bit worse. For the Gaussian, the result is in general much better. As expected, the quadratic cells have an easier time outperforming the linear cells for a small number of bins. The following plots show the ratio of the average variance reduction between the new piecewise-quadratic and the already existing piecewise-linear coupling cells.

ndeutschmann commented 4 years ago

Many thanks for your update Niklas, I must say it works really beautifully! Look at that Camel function in 4D

image

However I would still like you to improve the comments on the transform part, we should discuss this directly.