Where


tensorflow C++ API

tensorflow::ops::Where

Returns locations of true values in a boolean tensor.


Summary

This operation returns the coordinates of true elements incondition. The coordinates are returned in a 2-D tensor where the first dimension (rows) represents the number of true elements, and the second dimension (columns) represents the coordinates of the true elements. Keep in mind, the shape of the output tensor can vary depending on how many true values there are incondition. Indices are output in row-major order.

For example:

``` 'input' tensor is [[True, False]

[True, False]]

'input' has two true values, so output has two coordinates.

'input' has rank of 2, so coordinates have two indices.

where(input) ==> [[0, 0], [1, 0]]

conditiontensor is [[[True, False]

[True, False]]

[[False, True]

[False, True]]

[[False, False]

[False, True]]]

'input' has 5 true values, so output has 5 coordinates.

'input' has rank of 3, so coordinates have three indices.

where(input) ==> [[0, 0, 0], [0, 1, 0], [1, 0, 1], [1, 1, 1], [2, 1, 1]] ```

Arguments:

Returns:


Where block

Source link :https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_array_ops.cpp

Argument:

  • Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
  • Input condition: A boolean type of Tensor.

Output:

  • Output index: Output object of Where class object.

Result:

  • std::vector(Tensor) result_index: Indicates the index where the value is true in the condition

Using Method


※ condition에서 값이 참인 곳을 찾아서 index로 내보낸다. 위 그림에서 condition의 값이 참인 경우가 5개 이고 3-RANK tensor이므로 결과의 shape는 {5, 3}이 되고, 각각의 위치를 나타낸다.

results matching ""

    No results matching ""