mars.tensor.
identity
Return the identity tensor.
The identity tensor is a square array with ones on the main diagonal.
n (int) – Number of rows (and columns) in n x n output.
dtype (data-type, optional) – Data-type of the output. Defaults to float.
float
sparse (bool, optional) – Create sparse tensor if True, False as default
gpu (bool, optional) – Allocate the tensor on GPU if True, False as default
chunks (int or tuple of int or tuple of ints, optional) – Desired chunk size on each dimension
out – n x n array with its main diagonal set to one, and all other elements 0.
Tensor
Examples
>>> import mars.tensor as mt
>>> mt.identity(3).execute() array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]])