Warning: This API is deprecated and will be removed in a future
version of TensorFlow after
the replacement is stable.
Unique
Stay organized with collections
Save and categorize content based on your preferences.
Finds unique elements along an axis of a tensor.
This operation either returns a tensor `y` containing unique elements
along the `axis` of a tensor. The returned unique elements is sorted
in the same order as they occur along `axis` in `x`.
This operation also returns a tensor `idx` that is the same size as
the number of the elements in `x` along the `axis` dimension. It
contains the index in the unique output `y`.
In other words, for an `1-D` tensor `x` with `axis = None:
`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]
For an `2-D` tensor `x` with `axis = 0`:
# tensor 'x' is [[1, 0, 0],
# [1, 0, 0],
# [2, 0, 0]]
y, idx = unique(x, axis=0)
y ==> [[1, 0, 0],
[2, 0, 0]]
idx ==> [0, 0, 1]
For an `2-D` tensor `x` with `axis = 1`:
# tensor 'x' is [[1, 0, 0],
# [1, 0, 0],
# [2, 0, 0]]
y, idx = unique(x, axis=1)
y ==> [[1, 0],
[1, 0],
[2, 0]]
idx ==> [0, 1, 1]
Public Methods
static
<T, V extends Number, U extends Number>
Unique<T, V>
|
create( Scope scope, Operand<T> x, Operand<U> axis, Class<V> outIdx)
Factory method to create a class wrapping a new Unique operation.
|
static
<T, U extends Number>
Unique<T, Integer>
|
create( Scope scope, Operand<T> x, Operand<U> axis)
Factory method to create a class wrapping a new Unique operation using default output types.
|
Output<V>
|
|
Output<T>
|
|
Inherited Methods
From class
java.lang.Object
boolean
|
equals(Object arg0)
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Methods
public
static
Unique<T, V>
create
(Scope scope, Operand<T> x, Operand<U> axis, Class<V> outIdx)
Factory method to create a class wrapping a new Unique operation.
Parameters
scope |
current scope |
x |
A `Tensor`. |
axis |
A `Tensor` of type `int32` (default: None). The axis of the Tensor to
find the unique elements. |
public
static
Unique<T, Integer>
create
(Scope scope, Operand<T> x, Operand<U> axis)
Factory method to create a class wrapping a new Unique operation using default output types.
Parameters
scope |
current scope |
x |
A `Tensor`. |
axis |
A `Tensor` of type `int32` (default: None). The axis of the Tensor to
find the unique elements. |
public
Output<V>
idx
()
A 1-D Tensor. Has the same type as x that contains the index of each
value of x in the output y.
public
Output<T>
y
()
A `Tensor`. Unique elements along the `axis` of `Tensor` x.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-02-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-02-12 UTC."],[],[],null,["# Unique\n\npublic final class **Unique** \nFinds unique elements along an axis of a tensor.\n\n\nThis operation either returns a tensor \\`y\\` containing unique elements\nalong the \\`axis\\` of a tensor. The returned unique elements is sorted\nin the same order as they occur along \\`axis\\` in \\`x\\`.\nThis operation also returns a tensor \\`idx\\` that is the same size as\nthe number of the elements in \\`x\\` along the \\`axis\\` dimension. It\ncontains the index in the unique output \\`y\\`.\nIn other words, for an \\`1-D\\` tensor \\`x\\` with \\`axis = None:\n\n\n\\`y\\[idx\\[i\\]\\] = x\\[i\\] for i in \\[0, 1,...,rank(x) - 1\\]\\`\n\n\nFor example: \n\n # tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]\n y, idx = unique(x)\n y ==> [1, 2, 4, 7, 8]\n idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4]\n \nFor an \\`2-D\\` tensor \\`x\\` with \\`axis = 0\\`: \n\n # tensor 'x' is [[1, 0, 0],\n # [1, 0, 0],\n # [2, 0, 0]]\n y, idx = unique(x, axis=0)\n y ==> [[1, 0, 0],\n [2, 0, 0]]\n idx ==> [0, 0, 1]\n \nFor an \\`2-D\\` tensor \\`x\\` with \\`axis = 1\\`: \n\n # tensor 'x' is [[1, 0, 0],\n # [1, 0, 0],\n # [2, 0, 0]]\n y, idx = unique(x, axis=1)\n y ==> [[1, 0],\n [1, 0],\n [2, 0]]\n idx ==> [0, 1, 1]\n \n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Public Methods\n\n|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static \\\u003cT, V extends Number, U extends Number\\\u003e [Unique](/api_docs/java/org/tensorflow/op/core/Unique)\\\u003cT, V\\\u003e | [create](/api_docs/java/org/tensorflow/op/core/Unique#create(org.tensorflow.op.Scope,%20org.tensorflow.Operand\u003cT\u003e,%20org.tensorflow.Operand\u003cU\u003e,%20java.lang.Class\u003cV\u003e))([Scope](/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e x, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cU\\\u003e axis, Class\\\u003cV\\\u003e outIdx) Factory method to create a class wrapping a new Unique operation. |\n| static \\\u003cT, U extends Number\\\u003e [Unique](/api_docs/java/org/tensorflow/op/core/Unique)\\\u003cT, Integer\\\u003e | [create](/api_docs/java/org/tensorflow/op/core/Unique#create(org.tensorflow.op.Scope,%20org.tensorflow.Operand\u003cT\u003e,%20org.tensorflow.Operand\u003cU\u003e))([Scope](/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e x, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cU\\\u003e axis) Factory method to create a class wrapping a new Unique operation using default output types. |\n| [Output](/api_docs/java/org/tensorflow/Output)\\\u003cV\\\u003e | [idx](/api_docs/java/org/tensorflow/op/core/Unique#idx())() A 1-D Tensor. |\n| [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | [y](/api_docs/java/org/tensorflow/op/core/Unique#y())() A \\`Tensor\\`. |\n\n### Inherited Methods\n\nFrom class [org.tensorflow.op.PrimitiveOp](/api_docs/java/org/tensorflow/op/PrimitiveOp) \n\n|------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|\n| final boolean | [equals](/api_docs/java/org/tensorflow/op/PrimitiveOp#equals(java.lang.Object))(Object obj) |\n| final int | [hashCode](/api_docs/java/org/tensorflow/op/PrimitiveOp#hashCode())() |\n| [Operation](/api_docs/java/org/tensorflow/Operation) | [op](/api_docs/java/org/tensorflow/op/PrimitiveOp#op())() Returns the underlying [Operation](/api_docs/java/org/tensorflow/Operation) |\n| final String | [toString](/api_docs/java/org/tensorflow/op/PrimitiveOp#toString())() |\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public static [Unique](/api_docs/java/org/tensorflow/op/core/Unique)\\\u003cT, V\\\u003e\n**create**\n([Scope](/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e x, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cU\\\u003e axis, Class\\\u003cV\\\u003e outIdx)\n\nFactory method to create a class wrapping a new Unique operation. \n\n##### Parameters\n\n| scope | current scope |\n| x | A \\`Tensor\\`. |\n| axis | A \\`Tensor\\` of type \\`int32\\` (default: None). The axis of the Tensor to find the unique elements. |\n|-------|-----------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- a new instance of Unique \n\n#### public static [Unique](/api_docs/java/org/tensorflow/op/core/Unique)\\\u003cT, Integer\\\u003e\n**create**\n([Scope](/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e x, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cU\\\u003e axis)\n\nFactory method to create a class wrapping a new Unique operation using default output types. \n\n##### Parameters\n\n| scope | current scope |\n| x | A \\`Tensor\\`. |\n| axis | A \\`Tensor\\` of type \\`int32\\` (default: None). The axis of the Tensor to find the unique elements. |\n|-------|-----------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- a new instance of Unique \n\n#### public [Output](/api_docs/java/org/tensorflow/Output)\\\u003cV\\\u003e\n**idx**\n()\n\nA 1-D Tensor. Has the same type as x that contains the index of each\nvalue of x in the output y. \n\n#### public [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e\n**y**\n()\n\nA \\`Tensor\\`. Unique elements along the \\`axis\\` of \\`Tensor\\` x."]]