Method invert
static member invert: Tensor<'T> -> Tensor<'T>
(Batch) inverts a matrix.
Declaration
static member invert: a:Tensor<'T> -> Tensor<'T>
Parameters
Type | Name | Description |
---|---|---|
Tensor<'T> | a | The input matrix or tensor to this operation. |
Returns
Type | Description |
---|---|
Tensor<'T> | A new matrix or tensor containing the result of this operation. |
Remarks
If a
is a square matrix, its inverse is computed. The result is a matrix.
If a
is a tensor of shape [b_1; ...; b_n; i; i]
, the inverse
of all square matrices consisting of the last two dimensions of the tensor are computed.
The result is a tensor of same shape.
If the matrix is not invertible a SingularMatrixException is raised. Use static member pseudoInvert: Tensor<'T> * 'T option -> Tensor<'T> for such matrices instead.
Examples
let a = HostTensor.ofList [[1.0; 2.0]
[3.0; 4.0]]
let c = Tensor.invert a // c = [[-2.0; 1.0]
// [1.5; -0.5]]
Exceptions
Type | Condition |
---|---|
SingularMatrixException | Raised when the matrix is not invertible. |