bayesiains / nflows

Normalizing flows in PyTorch
MIT License
845 stars 118 forks source link

Tensor construction warnings #1

Closed alvorithm closed 4 years ago

alvorithm commented 4 years ago

This PR adds a little helper function to prevent tensor construction warnings when passing a torch.Tensor-typed argument to torch.tensor().

alvorithm commented 4 years ago

Re. AffineTransform replacing AffineScalarTransform the test fails on the logabsdet of the inverse in standard_test.py::AffineScalarTransformTest. I could have a look tomorrow, if you don't immediately see the reason.

alvorithm commented 4 years ago

Ok, the commits above implement all the changes we've discussed so far

Note I had to special-case scalar scale to match the expectation of the tests to within eps=1E-6. Using the .sum() idiom leads to disagreements ~1E-5, and is perhaps slower. But now the special casing is confined to a little function, where it can be suitably documented. Also, this function could be memoized if the transform is applied multiple times (or even in fwd and inv modes) with the same batch_shape.

alvorithm commented 4 years ago

Thanks, Artur, and please keep the nitpicks coming, I love them!

In this installment

alvorithm commented 4 years ago