mars.tensor.unravel_index#
- mars.tensor.unravel_index(indices, dims, order='C')[源代码]#
Converts a flat index or tensor of flat indices into a tuple of coordinate tensors.
- 参数
indices (array_like) – An integer tensor whose elements are indices into the flattened version of a tensor of dimensions
dims
.dims (tuple of ints) – The shape of the tensor to use for unraveling
indices
.order ({'C', 'F'}, optional) – Determines whether the indices should be viewed as indexing in row-major (C-style) or column-major (Fortran-style) order.
- 返回
unraveled_coords – Each tensor in the tuple has the same shape as the
indices
tensor.- 返回类型
tuple of Tensor
参见
ravel_multi_index
实际案例
>>> import mars.tensor as mt
>>> mt.unravel_index([22, 41, 37], (7,6)).execute() (array([3, 6, 6]), array([4, 5, 1]))
>>> mt.unravel_index(1621, (6,7,8,9)).execute() (3, 1, 4, 1)