Τransforms

Affine Transform

class sinflow.transforms.AffineTransform(eps=1e-09)

Affine transformation.

Parameters:

eps: float, default=1e-9

Small constant to add to the covariance matrix for numerical stability.

fit(x)

Fit the affine transformation to the given data.

Parameters:

xnumpy.ndarray

Data to fit the transformation to.

forward(x)

Apply the forward transformation to the given data.

Parameters:

xnumpy.ndarray

Data to transform.

Returns:

ynumpy.ndarray

Transformed data.

log_detnumpy.ndarray

Logarithm of the determinant of the Jacobian of the transformation.

inverse(y)

Apply the inverse transformation to the given data.

Parameters:

ynumpy.ndarray

Data to transform.

Returns:

xnumpy.ndarray

Transformed data.

log_detnumpy.ndarray

Logarithm of the determinant of the Jacobian of the transformation.

Spline Transform

class sinflow.transforms.SplineTransform(n_knots=1000, bandwidth=None)

Monotonic spline transformation.

Parameters:

n_knotsint, default=1000

Number of knots to use in the spline.

bandwidthfloat, default=None

Bandwidth for the KDEs. If not provided, Silverman’s rule of thumb is used.

epsfloat, default=1e-6

Small constant to add to the spline values for numerical stability.

fit(x)

Fit the monotonic spline transformation to the given data.

Parameters:

xnumpy.ndarray

Data to fit the transformation to.

forward(x)

Apply the forward transformation to the given data.

Parameters:

xnumpy.ndarray

Data to transform.

Returns:

ynumpy.ndarray

Transformed data.

log_detnumpy.ndarray

Logarithm of the determinant of the Jacobian of the transformation.

inverse(y)

Apply the inverse transformation to the given data.

Parameters:

ynumpy.ndarray

Data to transform.

Returns:

xnumpy.ndarray

Transformed data.

log_detnumpy.ndarray

Logarithm of the determinant of the Jacobian of the transformation.

Projected Spline Transform

class sinflow.transforms.ProjectedSplineTransform(direction, n_knots=1000, bandwidth=None)

Monotonic spline transformation along an arbitrary direction.

Parameters:

directionnumpy.ndarray of shape (D,)

Unit direction vector along which the spline transform is applied.

n_knotsint, default=1000

Number of knots to use in the spline.

bandwidthfloat, default=None

Bandwidth for the KDE. If not provided, Silverman’s rule of thumb is used.

fit(x)

Fit the monotonic spline transformation to the given data along the specified direction.

Parameters:

xnumpy.ndarray of shape (N, D)

Data to fit the transformation to.

forward(x)

Apply the forward transformation to the given data.

Parameters:

xnumpy.ndarray of shape (N, D)

Data to transform.

Returns:

ynumpy.ndarray of shape (N, D)

Transformed data.

log_detnumpy.ndarray of shape (N,)

Logarithm of the determinant of the Jacobian of the transformation.

inverse(y)

Apply the inverse transformation to the given data.

Parameters:

ynumpy.ndarray of shape (N, D)

Data to inverse transform.

Returns:

xnumpy.ndarray of shape (N, D)

Inverse transformed data.

log_detnumpy.ndarray of shape (N,)

Logarithm of the determinant of the Jacobian of the inverse transformation.