Link Search Menu Expand Document

SetDiff1D


tensorflow C++ API

tensorflow::ops::SetDiff1D

Computes the difference between two lists of numbers or strings.


Summary

Given a listxand a listy, this operation returns a listoutthat represents all values that are inxbut not iny. The returned listoutis sorted in the same order that the numbers appear inx(duplicates are preserved). This operation also returns a listidxthat represents the position of eachoutelement inx. In other words:

out[i] = x[idx[i]] for i in [0, 1, ..., len(out) - 1]

For example, given this input:

``` x = [1, 2, 3, 4, 5, 6] y = [1, 3, 5] ```

This operation would return:

``` out ==> [2, 4, 6] idx ==> [1, 3, 5] ```

Arguments:

  • scope: A Scope object
  • x: 1-D. Values to keep.
  • y: 1-D. Values to remove.

Returns:

  • Outputout: 1-D. Values present in x but not in y.
  • Outputidx: 1-D. Positions of x values preserved in out.

SetDiff1D 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: 1-D. Values to keep.
  • Input y: 1-D. Values to remove.
  • SetDiff1D::Attrs attrs
    • out_idx : The type of idx tensor.(DT_INT32, DT_INT64, DT_FLOAT, DT_DOUBLE….. etc)

Output:

  • Output out: Output object of SetDiff1D class object.
  • Output idx: Output object of SetDiff1D class object.

Result:

  • std::vector(Tensor) result_out: 1-D. Values present in x but not in y.
  • std::vector(Tensor) result_idx: 1-D. Positions of x values preserved in out.

Using Method


※ x의 value에서 y에 있는 value와 같은 값을 지워버린다. out은 y에 해당하는 값을 지우고 남은 x이고, idx는 남아있는 x값이 y에 의해 지워지기 전의 index값을 나열한 것이다.