当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python tf.raw_ops.UnravelIndex用法及代码示例


将平面索引数组转换为坐标数组元组。

用法

tf.raw_ops.UnravelIndex(
    indices, dims, name=None
)

参数

  • indices 一个Tensor。必须是以下类型之一:int32 , int64。一个 0-D 或 1-D int 张量,其元素是维度数组的扁平版本的索引。
  • dims 一个Tensor。必须与 indices 具有相同的类型。一维int张量。用于解开索引的数组的形状。
  • name 操作的名称(可选)。

返回

  • 一个Tensor。具有与 indices 相同的类型。

例子:

y = tf.unravel_index(indices=[2, 5, 7], dims=[3, 3])
# 'dims' represent a hypothetical (3, 3) tensor of indices:
# [[0, 1, *2*],
#  [3, 4, *5*],
#  [6, *7*, 8]]
# For each entry from 'indices', this operation returns
# its coordinates (marked with '*'), such as
# 2 ==> (0, 2)
# 5 ==> (1, 2)
# 7 ==> (2, 1)
y ==> [[0, 1, 2], [2, 2, 1]]

numpy 兼容性

相当于 np.unravel_index

相关用法


注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.UnravelIndex。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。