Pytorch implementation of some flow architectures.
Please use this Google Chrome extension to visualise equations in the Readme.md file.
The core structure of the flow is implemented in flows.py
.
The Flow
object is defined by a base distribution
- We can learn the parameters
$\Phi</code>$</em>, fitting the flow-based model to a set of observations <code>x_samples</code> by MLE in order to approximate the corresponding density $<code>p_x$ by calling thetrain
method. - We can easily sample from this Flow-object (
sample
method) and evaluate its probability density function (learned_log_pdf
method). These are the main features of the Flow-object, that are based on the following formulas:
For sampling we use the forward transformation:
To evaluate the pdf we use the inverse transformation:
The different transformations are implemented in transforms.py
. They are defined by a set of learnable parameters torch.nn.Parameter
class and the above mentioned methods forward_transform
and inverse_transform
.
AffineElementwiseTransform
:
The parameters to learn are
PositiveLinearTransformation
:
where