maxframe.tensor.unravel_index#

maxframe.tensor.unravel_index(indices, dims, order='C')[源代码]#

将一个平坦索引或平坦索引张量转换为坐标张量的元组。

参数:
  • indices (array_like) -- 一个整数张量,其元素是维度为 dims 的张量展平后的索引。

  • dims (tuple of ints) -- 用于展开 indices 的张量的形状。

  • order ({'C', 'F'}, optional) -- 确定索引应被视为按行主序(C 风格)还是列主序(Fortran 风格)进行索引。

返回:

unraveled_coords -- 元组中的每个张量都与 indices 张量具有相同的形状。

返回类型:

tuple of Tensor

参见

ravel_multi_index

示例

>>> import maxframe.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)