Apply an orthogonal or unitary parametrization to a matrix or a batch of matrices.
Letting K be or , the parametrized
matrix is as
R
C
Q∈Km×n
orthogonal
QHQQQH=Inif m≥n=Imif m<n
where QH is the conjugate transpose when Q is complex
and the transpose when Q is real-valued, and
In is the n-dimensional identity matrix.
In plain words, Q will have orthonormal columns whenever m≥n
and orthonormal rows otherwise.
If the tensor has more than two dimensions, we consider it as a batch of matrices of shape (…, m, n).
The matrix Q may be parametrized via three different orthogonal_map in terms of the original tensor:
"matrix_exp"/"cayley":
the matrix_exp()Q=exp(A) and the Cayley mapQ=(In+A/2)(In−A/2)−1 are applied to a skew-symmetric
A to give an orthogonal matrix.
"householder": computes a product of Householder reflectors
(householder_product()).
"matrix_exp"/"cayley" often make the parametrized weight converge faster than
"householder", but they are slower to compute for very thin or very wide matrices.
If use_trivialization=True (default), the parametrization implements the “Dynamic Trivialization Framework”,
where an extra matrix B∈Kn×n is stored under
module.parametrizations.weight[0].base. This helps the
convergence of the parametrized layer at the expense of some extra memory use.
See Trivializations for Gradient-Based Optimization on Manifolds .
Initial value of Q:
If the original tensor is not parametrized and use_trivialization=True (default), the initial value
of Q is that of the original tensor if it is orthogonal (or unitary in the complex case)
and it is orthogonalized via the QR decomposition otherwise (see torch.linalg.qr()).
Same happens when it is not parametrized and orthogonal_map="householder" even when use_trivialization=False.
Otherwise, the initial value is the result of the composition of all the registered
parametrizations applied to the original tensor.
Parameters:
module (nn.Module) – module on which to register the parametrization.
name (str, optional) – name of the tensor to make orthogonal. Default: "weight".
orthogonal_map (str, optional) – One of the following: "matrix_exp", "cayley", "householder".
Default: "matrix_exp" if the matrix is square or complex, "householder" otherwise.
use_trivialization (bool, optional) – whether to use the dynamic trivialization framework.
Default: True.
Returns:
The original module with an orthogonal parametrization registered to the specified
weight