Method traceAxis
static member traceAxis: int -> int -> Tensor<'T> -> Tensor<'T>
Calculates the trace along the specified axes.
Declaration
static member traceAxis: ax1:int -> ax2:int -> a:Tensor<'T> -> Tensor<'T>
Parameters
Type | Name | Description |
---|---|---|
int | ax1 | The first axis of the diagonal to compute the trace along. |
int | ax2 | The second axis of the diagonal to compute the trace along. |
Tensor<'T> | a | The tensor containing the source values. |
Returns
Type | Description |
---|---|
Tensor<'T> | A new tensor containing the result of this operation. |
Remarks
The trace is calculated along the specified axes. It is defined by the sum of the elements on the diagonal.
The tensor must have the same size in dimensions ax1
and ax2
.
Examples
let a = HostTensor.zeros [2L; 3L; 4L; 3L]
let b = Tensor.traceAxis 1 3 a // b.Shape = [2L; 4L]