tf.unravel_index
Преобразует массив плоских индексов в кортеж массивов координат.
tf.unravel_index(
indices: Annotated[Any, TV_UnravelIndex_Tidx],
dims: Annotated[Any, TV_UnravelIndex_Tidx],
name=None
) -> Annotated[Any, TV_UnravelIndex_Tidx]
Пример:
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]]
| Аргументы | |
|---|---|
indices | A Tensor. Должен быть одного из следующих типов: int32, int64. 0-мерный или 1-мерный int тензор, элементы которого являются индексами в сплющенной версии массива с размерами dims. |
dims | A Tensor. Должен иметь тот же тип, что и indices. 1-мерный int тензор. Форма массива, используемого для распаковки индексов. |
name | Имя операции (необязательно). |
| Возвращаемое значение | |
|---|---|
A Tensor. Имеет тот же тип, что и indices. |
Совместимость с numpy
Эквивалентно np.unravel_index
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/unravel_index