Product of form a inv(X) b
Allocates a square matrix with the given vector as its diagonal.
Return a triangular matrix square root of positive semi-definite x
L = cholesky(X, lower=True) implies dot(L, L.T) == X
Implements the “reverse-mode” gradient [1] for the Cholesky factorization of a positive-definite matrix.
[1] | S. P. Smith. “Differentiation of the Cholesky Algorithm”. Journal of Computational and Graphical Statistics, Vol. 4, No. 2 (Jun.,1995), pp. 134-147 http://www.jstor.org/stable/1390762 |
Matrix determinant Input should be a square matrix
Compute the eigenvalues and right eigenvectors of a square array.
Function exposing different properties of each instance of the op.
For the Eig op, there are no properties to be exposed.
Return the eigenvalues and eigenvectors of a Hermitian or symmetric matrix.
The gradient function should return
where [,
] corresponds to g_outputs,
to inputs, and
.
Analytic formulae for eigensystem gradients are well-known in perturbation theory:
Gradient of an eigensystem of a Hermitian matrix.
Implements the “reverse-mode” gradient for the eigensystem of a square matrix.
Return the diagonal of a matrix.
For some reason numpy.diag(x) is really slow, so we implemented our own.
Provide arbitrary information to the optimizer
These ops are removed from the graph during canonicalization in order to not interfere with other optimizations. The idea is that prior to canonicalization, one or more Features of the fgraph should register the information contained in any Hint node, and transfer that information out of the graph.
FunctionGraph Feature to track matrix properties
This is a similar feature to variable ‘tags’. In fact, tags are one way to provide hints.
This class exists because tags were not documented well, and the semantics of how tag information should be moved around during optimizations was never clearly spelled out.
Hints are assumptions about mathematical properties of variables. If one variable is substituted for another by an optimization, then it means that the assumptions should be transferred to the new variable.
Hints are attached to ‘positions in a graph’ rather than to variables in particular, although Hints are originally attached to a particular positition in a graph via a variable in that original graph.
Examples of hints are: - shape information - matrix properties (e.g. symmetry, psd, banded, diagonal)
Hint information is propagated through the graph similarly to graph optimizations, except that adding a hint does not change the graph. Adding a hint is not something that debugmode will check.
#TODO: should a Hint be an object that can actually evaluate its # truthfulness? # Should the PSD property be an object that can check the # PSD-ness of a variable?
Optimizer that serves to add HintsFeature as an fgraph feature.
Computes the inverse of a matrix .
Given a square matrix , matrix_inverse returns a square
matrix
such that the dot product
and
equals the identity matrix
.
Note : | When possible, the call to this op will be optimized to the call of solve. |
---|
The gradient function should return
where corresponds to g_outputs and
to
inputs. Using the matrix cookbook,
once can deduce that the relation corresponds to
The gradient function should return
where corresponds to g_outputs and
to
inputs. Using the matrix cookbook,
once can deduce that the relation corresponds to
Function exposing different properties of each instance of the op.
For the MatrixInverse op, there are no properties to be exposed.
Computes the pseudo-inverse of a matrix .
The pseudo-inverse of a matrix A, denoted , is
defined as: “the matrix that ‘solves’ [the least-squares problem]
,” i.e., if
is said solution, then
is that matrix such that
.
Note that , so
is close to the identity matrix.
This method is not faster then matrix_inverse. Its strength comes from
that it works for non-square matrices.
If you have a square matrix though, matrix_inverse can be both more
exact and faster to compute. Also this op does not get optimized into a
solve op.
Function exposing different properties of each instance of the op.
For the MatrixPinv op, there are no properties to be exposed.
Solve a system of linear equations
Numpy-compatibility method If x is a matrix, return its diagonal. If x is a vector return a matrix with it as its diagonal.
Shorthand for product between several dots
Given matrices
, matrix_dot will
generate the matrix product between all in the given order, namely
.
Apply a hint that the variable v is positive semi-definite, i.e.
it is a symmetric matrix and for any vector x.
Returns upper bound on the largest eigenvalue of square symmetrix matrix X.
log2_exponent must be a positive-valued integer. The larger it is, the slower and tighter the bound. Values up to 5 should usually suffice. The algorithm works by multiplying X by itself this many times.
From V.Pan, 1990. “Estimating the Extremal Eigenvalues of a Symmetric Matrix”, Computers Math Applic. Vol 20 n. 2 pp 17-22. Rq: an efficient algorithm, not used here, is defined in this paper.
Returns the sum of diagonal elements of matrix X.