Flows¶
CNeuralAffine
¶
A specification for the coupling-neural affine flow, also known as the real-valued non-volume-preserving (real NVP) flow.
Definition
Given an input \(\mathbf{z}\) with \(D\) elements, we first partition them into \(\mathbf{z}_{1:d}\) and \(\mathbf{z}_{d+1:D}\). Then the transformation is given as:
Where \(\mathbf{z} \in \mathbb{R}^D\), \(\mathbf{s} \in \mathbb{R}^{D/2}\) is non-negative, and \(\mathbf{c} \in \mathbb{R}^{D/2}\). Both \(\mathbf{s}\) and \(\mathbf{c}\) are joint outputs of a neural network.
Attributes:
| Name | Type | Description |
|---|---|---|
hidden_size |
int
|
The width of the hidden layers for the neural network. |
depth |
int
|
The number of hidden layers for the neural network. |
activation |
Callable[[Array], Array]
|
The activation function to be used in between layers for the neural network. |
flip |
bool
|
Whether to flip the mask (which elements are the 'conditioner's and which are the 'transformer's). |
key |
PRNGKeyArray
|
The PRNG key used to generate the flow layer. |
Source code in src/bayinx/flows/cneural_affine.py
DiagAffine
¶
A specification for the diagonal affine flow.
Definition
\(T(\mathbf{z}) = \mathbf{d} \odot \mathbf{z} + \mathbf{c}\)
Where \(\mathbf{z} \in \mathbb{R}^D\), \(\mathbf{d} \in \mathbb{R}^{D}\) is non-negative, and \(\mathbf{c} \in \mathbb{R}^D\).
Attributes:
| Name | Type | Description |
|---|---|---|
key |
PRNGKeyArray
|
The PRNG key used to generate the diagonal affine flow layer. |
Source code in src/bayinx/flows/diagaffine.py
FullAffine
¶
A specification for the full affine flow.
Definition
\(T(\mathbf{z}) = \mathbf{L z} + \mathbf{c}\)
Where \(\mathbf{z} \in \mathbb{R}^D\), \(\mathbf{L} \in \mathbb{R}^{D, D}\) is lower triangular with a non-negative diagonal, and \(\mathbf{c} \in \mathbb{R}^D\).
Attributes:
| Name | Type | Description |
|---|---|---|
key |
PRNGKeyArray
|
The PRNG key used to generate the full affine flow layer. |
Source code in src/bayinx/flows/fullaffine.py
__init__(key: PRNGKeyArray = jr.key(0))
¶
Initializes the specification for a full affine flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKeyArray
|
A PRNG key used to generate the full affine flow. |
key(0)
|
construct(dim: int) -> FullAffineLayer
¶
Constructs a full affine flow layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
The dimension of the parameter space. |
required |
Returns:
| Type | Description |
|---|---|
FullAffineLayer
|
A FullAffineLayer of dimension |
Source code in src/bayinx/flows/fullaffine.py
LinearRationalSpline
¶
A specification for a modified linear rational splines flow.
Definition
The transformation \(T(z)\) is defined as:
Where for each dimension \(d \in \{1, \dots, D\}\) we centre the spline at \(\tilde{z} = z - s\), the knots are denoted by \(\{x_k, y_k\}_{k=0}^K\) and derivatives by \(\{\delta_k\}_{k=0}^K\), with shift \(s\). The linear-rational segment for bin \(b\) is denoted by \(\text{LR}_b(z)\), and is parameterized by its knots \((x_b, y_b), (x_{b+1}, y_{b+1})\), derivatives at each knot \(\delta_b, \delta_{b+1}\), and midpoint weight \(\lambda_b\) controlling the curvature.
Attributes:
| Name | Type | Description |
|---|---|---|
n_bins |
int
|
The number of bins covering the boundary. |
key |
PRNGKeyArray
|
The PRNG key used to generate the diagonal affine flow layer. |
Source code in src/bayinx/flows/lrs.py
RealNVP
¶
A specification for the coupling-neural affine flow, also known as the real-valued non-volume-preserving (real NVP) flow.
Definition
Given an input \(\mathbf{z}\) with \(D\) elements, we first partition them into \(\mathbf{z}_{1:d}\) and \(\mathbf{z}_{d+1:D}\). Then the transformation is given as:
Where \(\mathbf{z} \in \mathbb{R}^D\), \(\mathbf{s} \in \mathbb{R}^{D/2}\) is non-negative, and \(\mathbf{c} \in \mathbb{R}^{D/2}\). Both \(\mathbf{s}\) and \(\mathbf{c}\) are joint outputs of a neural network.
Attributes:
| Name | Type | Description |
|---|---|---|
hidden_size |
int
|
The width of the hidden layers for the neural network. |
depth |
int
|
The number of hidden layers for the neural network. |
activation |
Callable[[Array], Array]
|
The activation function to be used in between layers for the neural network. |
flip |
bool
|
Whether to flip the mask (which elements are the 'conditioner's and which are the 'transformer's). |
key |
PRNGKeyArray
|
The PRNG key used to generate the flow layer. |