osc.utils.ravel_multi_index_tf

ravel_multi_index_tf(multi_index: Tuple[tensorflow.python.framework.ops.Tensor, ...], dims: Tuple[int, ...]) tensorflow.python.framework.ops.Tensor[source]

Same as :func:np.ravel_multi_index with no checks.

Parameters
  • multi_index (Tuple[Tensor, ...]) – a tuple of index tensors, one per dimension

  • dims (Tuple[int, ...]) – the shape of the tensor. The number of dimensions should be the same as the number of index tensors in multi_index. Also, all(multi_index[i] < dims[i]) is expected to hold for all i.

Example

How to use:

>>> ravel_multi_index_tf(
>>>   (
>>>     tf.constant([4, 3, 3, 2]),
>>>     tf.constant([0, 1, 5, 6]),
>>>     tf.constant([0, 1, 2, 0]),
>>>   ),
>>>   dims=(5, 7, 3)
>>> )
[84, 67, 80, 60]
Return type

Tensor

Returns

A 1D tensor of flat indexes.