InvertibleMatrix

class tfsnippet.InvertibleMatrix(size, strict=False, dtype=tf.float32, epsilon=1e-06, trainable=True, random_state=None, name=None, scope=None)

Bases: tfsnippet.utils.reuse.VarScopeObject

A matrix initialized to be an invertible, orthogonal matrix.

If strict is False, then there is no guarantee that the matrix will keep invertible during training. Otherwise, the matrix will be derived through a variant of PLU decomposition as proposed in (Kingma & Dhariwal, 2018):

\[\mathbf{M} = \mathbf{P} \mathbf{L} (\mathbf{U} + \mathrm{diag}(\mathbf{sign} \odot \exp(\mathbf{s})))\]

where P is a permutation matrix, L is a lower triangular matrix with all its diagonal elements equal to one, U is an upper triangular matrix with all its diagonal elements equal to zero, sign is a vector of {-1, 1}, and s is a vector. P and sign are fixed variables, while L, U, s are trainable variables.

A random_state can be specified via the constructor. If it is not specified, an instance of VarScopeRandomState will be created according to the variable scope name of the object.

Attributes Summary

inv_matrix Get the inverted matrix.
log_det Get the log-determinant of the matrix.
matrix Get the matrix tensor.
name Get the name of this object.
shape Get the shape of the matrix.
variable_scope Get the variable scope of this object.

Attributes Documentation

inv_matrix

Get the inverted matrix.

Returns:The inverted matrix tensor.
Return type:tf.Tensor
log_det

Get the log-determinant of the matrix.

Returns:The log-determinant tensor.
Return type:tf.Tensor
matrix

Get the matrix tensor.

Returns:The matrix tensor.
Return type:tf.Tensor or tf.Variable
name

Get the name of this object.

shape

Get the shape of the matrix.

Returns:The shape of the matrix.
Return type:(int, int)
variable_scope

Get the variable scope of this object.