Normalising Flow Layers#

Classes#

class SplineFlow(transforms, hidden_features, net_out, shapes, *, context=False, features=None, factor=None, **kwargs)[source]#

Bases: BaseLayer

Neural spline flow layer constructor.

Should only be used as the last layer in the network as it does not return a Tensor.

Attributes:
groupint

Layer group, if 0 it will always be used, else it will only be used if its group matches the Networks

descriptionstr

Description of the layer

Generates a neural spline flow (NSF) for use in BaseNetwork

Adds attributes of name (‘flow’), optimiser (Adam), and scheduler (ReduceLROnPlateau)

Parameters:
transformsint

Number of transforms

hidden_featureslist[int]

Number of features in each of the hidden layers

net_outlist[int]

Shape of the network’s output

shapesShapes

Shape of the outputs from each layer

contextbool, Optional

If the output from the previous layer should be used to condition the normalising flow, default = False

featuresint | NoneType, Optional

Dimensions of the probability distribution, if factor is provided, features will not be used

factorfloat | NoneType, Optional

Output features is equal to the factor of the network’s output, will be used if provided, else features will be used

**kwargs

Leftover parameters to pass to base layer for checking

forward(x, *_, **__)[source]#

Forward pass of the neural spline flow layer

Parameters:
xTensor

Input tensor with shape (N,…) and type float, where N is the batch size

Returns:
NormalizingFlow

Normalising flow distribution