Warning: This API is deprecated and will be removed in a future
version of TensorFlow after
the replacement is stable.
Reverse
Stay organized with collections
Save and categorize content based on your preferences.
Reverses specific dimensions of a tensor.
Given a `tensor`, and a `int32` tensor `axis` representing the set of
dimensions of `tensor` to reverse. This operation reverses each dimension
`i` for which there exists `j` s.t. `axis[j] == i`.
`tensor` can have up to 8 dimensions. The number of dimensions specified
in `axis` may be 0 or more entries. If an index is specified more than
once, a InvalidArgument error is raised.
For example:
# tensor 't' is [[[[ 0, 1, 2, 3],
# [ 4, 5, 6, 7],
# [ 8, 9, 10, 11]],
# [[12, 13, 14, 15],
# [16, 17, 18, 19],
# [20, 21, 22, 23]]]]
# tensor 't' shape is [1, 2, 3, 4]
# 'dims' is [3] or 'dims' is [-1]
reverse(t, dims) ==> [[[[ 3, 2, 1, 0],
[ 7, 6, 5, 4],
[ 11, 10, 9, 8]],
[[15, 14, 13, 12],
[19, 18, 17, 16],
[23, 22, 21, 20]]]]
# 'dims' is '[1]' (or 'dims' is '[-3]')
reverse(t, dims) ==> [[[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]
[[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]]]]
# 'dims' is '[2]' (or 'dims' is '[-2]')
reverse(t, dims) ==> [[[[8, 9, 10, 11],
[4, 5, 6, 7],
[0, 1, 2, 3]]
[[20, 21, 22, 23],
[16, 17, 18, 19],
[12, 13, 14, 15]]]]
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
Output<T>
asOutput
()
Returns the symbolic handle of a tensor.
Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is
used to obtain a symbolic handle that represents the computation of the input.
public
static
Reverse<T>
create
(Scope scope, Operand<T> tensor, Operand<U> axis)
Factory method to create a class wrapping a new Reverse operation.
Parameters
scope |
current scope |
tensor |
Up to 8-D. |
axis |
1-D. The indices of the dimensions to reverse. Must be in the range
`[-rank(tensor), rank(tensor))`. |
Returns
- a new instance of Reverse
public
Output<T>
output
()
The same shape as `tensor`.
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,["# Reverse\n\npublic final class **Reverse** \nReverses specific dimensions of a tensor.\n\n\nGiven a \\`tensor\\`, and a \\`int32\\` tensor \\`axis\\` representing the set of\ndimensions of \\`tensor\\` to reverse. This operation reverses each dimension\n\\`i\\` for which there exists \\`j\\` s.t. \\`axis\\[j\\] == i\\`.\n\n\n\\`tensor\\` can have up to 8 dimensions. The number of dimensions specified\nin \\`axis\\` may be 0 or more entries. If an index is specified more than\nonce, a InvalidArgument error is raised.\n\n\nFor example: \n\n # tensor 't' is [[[[ 0, 1, 2, 3],\n # [ 4, 5, 6, 7],\n # [ 8, 9, 10, 11]],\n # [[12, 13, 14, 15],\n # [16, 17, 18, 19],\n # [20, 21, 22, 23]]]]\n # tensor 't' shape is [1, 2, 3, 4]\n \n # 'dims' is [3] or 'dims' is [-1]\n reverse(t, dims) ==> [[[[ 3, 2, 1, 0],\n [ 7, 6, 5, 4],\n [ 11, 10, 9, 8]],\n [[15, 14, 13, 12],\n [19, 18, 17, 16],\n [23, 22, 21, 20]]]]\n \n # 'dims' is '[1]' (or 'dims' is '[-3]')\n reverse(t, dims) ==> [[[[12, 13, 14, 15],\n [16, 17, 18, 19],\n [20, 21, 22, 23]\n [[ 0, 1, 2, 3],\n [ 4, 5, 6, 7],\n [ 8, 9, 10, 11]]]]\n \n # 'dims' is '[2]' (or 'dims' is '[-2]')\n reverse(t, dims) ==> [[[[8, 9, 10, 11],\n [4, 5, 6, 7],\n [0, 1, 2, 3]]\n [[20, 21, 22, 23],\n [16, 17, 18, 19],\n [12, 13, 14, 15]]]]\n \n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Public Methods\n\n|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | [asOutput](/api_docs/java/org/tensorflow/op/core/Reverse#asOutput())() Returns the symbolic handle of a tensor. |\n| static \\\u003cT, U extends Number\\\u003e [Reverse](/api_docs/java/org/tensorflow/op/core/Reverse)\\\u003cT\\\u003e | [create](/api_docs/java/org/tensorflow/op/core/Reverse#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 tensor, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cU\\\u003e axis) Factory method to create a class wrapping a new Reverse operation. |\n| [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | [output](/api_docs/java/org/tensorflow/op/core/Reverse#output())() The same shape as \\`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\nFrom interface [org.tensorflow.Operand](/api_docs/java/org/tensorflow/Operand) \n\n|--------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| abstract [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | [asOutput](/api_docs/java/org/tensorflow/Operand#asOutput())() Returns the symbolic handle of a tensor. |\n\nPublic Methods\n--------------\n\n#### public [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e\n**asOutput**\n()\n\nReturns the symbolic handle of a tensor.\n\nInputs to TensorFlow operations are outputs of another TensorFlow operation. This method is\nused to obtain a symbolic handle that represents the computation of the input.\n\n\u003cbr /\u003e\n\n#### public static [Reverse](/api_docs/java/org/tensorflow/op/core/Reverse)\\\u003cT\\\u003e\n**create**\n([Scope](/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e tensor, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cU\\\u003e axis)\n\nFactory method to create a class wrapping a new Reverse operation. \n\n##### Parameters\n\n| scope | current scope |\n| tensor | Up to 8-D. |\n| axis | 1-D. The indices of the dimensions to reverse. Must be in the range \\`\\[-rank(tensor), rank(tensor))\\`. |\n|--------|---------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- a new instance of Reverse \n\n#### public [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e\n**output**\n()\n\nThe same shape as \\`tensor\\`."]]