DiagLinear

class pmrf.stats.DiagLinear(diag: Array)

Bases: AbstractLinearBijector

Linear bijector with a diagonal weight matrix.

The bijector is defined as \(f(x) = Ax\) where \(A\) is a \(D \times D\) diagonal matrix. Additional dimensions, if any, index batches.

The Jacobian determinant is trivially computed by taking the product of the diagonal entries in \(A\). The inverse transformation \(x = f^{-1}(y)\) is computed element-wise.

The bijector is invertible if and only if the diagonal entries of A are all non-zero. It is the responsibility of the user to make sure that this is the case; the class will make no attempt to verify that the bijector is invertible.

Initializes the bijector.

Arguments:

  • diag: a vector of length D, the diagonal of matrix A.

forward(x: Array) → Array

Computes y = f(x).

forward_and_log_det(x: Array) → tuple[Array, Array]

Computes y = f(x) and log|det J(f)(x)|.

forward_log_det_jacobian(x: Array) → Array

Computes log|det J(f)(x)|.

inverse(y: Array) → Array

Computes x = f^{-1}(y).

inverse_and_log_det(y: Array) → tuple[Array, Array]

Computes x = f^{-1}(y) and log|det J(f^{-1})(y)|.

inverse_log_det_jacobian(y: Array) → Array

Computes log|det J(f^{-1})(y)|.

same_as(other: AbstractBijector) → bool

Returns True if this bijector is guaranteed to be the same as other.

diag: Array
event_dims: int
property matrix: Array

The full matrix A.