Unique


tensorflow C++ API

tensorflow::ops::Unique

Finds unique elements in a 1-D tensor.


Summary

This operation returns a tensorycontaining all of the unique elements ofxsorted in the same order that they occur inx. This operation also returns a tensoridxthe same size asxthat contains the index of each value ofxin the unique outputy. In other words:

y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]

For example:

``` tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]

y, idx = unique(x) y ==> [1, 2, 4, 7, 8] idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4] ```

Arguments:

  • scope: A Scope object
  • x: 1-D.

Returns:


Unique 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 x: A 1-D Tensor.
  • Unique::Attrs attrs:
    • out_idx: An optional. Specifies the type of idx. from: DT_INT32, DT_INT64. Defaults to DT_INT32.

Output:

  • Output y: Output object of Unique class object.
  • Output idx: Output object of Unique class object.

Result:

  • std::vector(Tensor) result_y: A Tensor . Has the same type as x. 1-D.
  • std::vector(Tensor) result_idx: A Tensor of type out_idx. 1-D.

Using Method


※ 중복되는 값을 모두 빼고, 유일한 값들만 남기는 기능을 한다. 결과값 y는 유니크한 값을 모아놓은 tensor이고, idx는 x에서 각각의 해당하는 값이 y에서 몇 번째 index인지 알려주는 역할을 한다. attrs의 out_idx는 idx의 데이터 타입을 지정한다.

results matching ""

    No results matching ""