ShapeUtils
Stay organized with collections
Save and categorize content based on your preferences.
Various methods for processing with Shapes and Operands
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
int[]
getIntArray
(Scope scope, Operand<TInt32> dims)
Converts a TInt32 type Operand to a Java int array
Parameters
scope |
the TensorFlow scope |
dims |
the shape dimensions operand |
Returns
- the int array of the dimensions
public
static
long[]
getLongArray
(T dims)
Converts a TInt32 or TInt64 to a java long array
Parameters
dims |
the dimension tensor |
Throws
IllegalArgumentException |
if the dims type is not an integer
|
public
static
long[]
getLongArray
(Scope scope, Operand<T> dims)
Converts a TInt32 or TInt64 Operand to a java long array
Parameters
scope |
the TensorFlow scope |
dims |
the Operand |
Throws
IllegalArgumentException |
if the dims type is not an integer
|
public
static
Shape
reduce
(Shape shape, int axis)
Reduces the shape by eliminating trailing Dimensions.
The last dimension, specified by axis, will be a product of all remaining dimensions
Parameters
shape |
the shape to squeeze |
axis |
the axis to squeeze |
public
static
Shape
toShape
(Scope scope, Operand<T> dims)
Converts a shape operand to a Shape object
Parameters
scope |
the TensorFlow scope |
dims |
the Operand containing the shape values |
Returns
- a new Shape based on an Operand that contains dimensions
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 2021-11-29 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 2021-11-29 UTC."],[],[],null,["# ShapeUtils\n\npublic class **ShapeUtils** \nVarious methods for processing with Shapes and Operands \n\n### Public Constructors\n\n|---|-------------------------------------------------------------------------------------------|\n| | [ShapeUtils](/jvm/api_docs/java/org/tensorflow/framework/utils/ShapeUtils#ShapeUtils())() |\n\n### Public Methods\n\n|-----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static int\\[\\] | [getIntArray](/jvm/api_docs/java/org/tensorflow/framework/utils/ShapeUtils#getIntArray(org.tensorflow.op.Scope, org.tensorflow.Operand\u003corg.tensorflow.types.TInt32\u003e))([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003c[TInt32](/jvm/api_docs/java/org/tensorflow/types/TInt32)\\\u003e dims) Converts a TInt32 type Operand to a Java int array |\n| static \\\u003cT extends [TIntegral](/jvm/api_docs/java/org/tensorflow/types/family/TIntegral)\\\u003e long\\[\\] | [getLongArray](/jvm/api_docs/java/org/tensorflow/framework/utils/ShapeUtils#getLongArray(T))(T dims) Converts a TInt32 or TInt64 to a java long array |\n| static \\\u003cT extends [TIntegral](/jvm/api_docs/java/org/tensorflow/types/family/TIntegral)\\\u003e long\\[\\] | [getLongArray](/jvm/api_docs/java/org/tensorflow/framework/utils/ShapeUtils#getLongArray(org.tensorflow.op.Scope, org.tensorflow.Operand\u003cT\u003e))([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e dims) Converts a TInt32 or TInt64 Operand to a java long array |\n| static [Shape](/jvm/api_docs/java/org/tensorflow/ndarray/Shape) | [reduce](/jvm/api_docs/java/org/tensorflow/framework/utils/ShapeUtils#reduce(org.tensorflow.ndarray.Shape, int))([Shape](/jvm/api_docs/java/org/tensorflow/ndarray/Shape) shape, int axis) Reduces the shape by eliminating trailing Dimensions. |\n| static \\\u003cT extends [TIntegral](/jvm/api_docs/java/org/tensorflow/types/family/TIntegral)\\\u003e [Shape](/jvm/api_docs/java/org/tensorflow/ndarray/Shape) | [toShape](/jvm/api_docs/java/org/tensorflow/framework/utils/ShapeUtils#toShape(org.tensorflow.op.Scope, org.tensorflow.Operand\u003cT\u003e))([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e dims) Converts a shape operand to a Shape object |\n\n### Inherited Methods\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 Constructors\n-------------------\n\n#### public\n**ShapeUtils**\n()\n\n\u003cbr /\u003e\n\nPublic Methods\n--------------\n\n#### public static int\\[\\]\n**getIntArray**\n([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003c[TInt32](/jvm/api_docs/java/org/tensorflow/types/TInt32)\\\u003e dims)\n\nConverts a TInt32 type Operand to a Java int array \n\n##### Parameters\n\n| scope | the TensorFlow scope |\n| dims | the shape dimensions operand |\n|-------|------------------------------|\n\n##### Returns\n\n- the int array of the dimensions \n\n#### public static long\\[\\]\n**getLongArray**\n(T dims)\n\nConverts a TInt32 or TInt64 to a java long array \n\n##### Parameters\n\n| dims | the dimension tensor |\n|------|----------------------|\n\n##### Returns\n\n- the long array \n\n##### Throws\n\n| IllegalArgumentException | if the dims type is not an integer |\n|--------------------------|------------------------------------|\n\n#### public static long\\[\\]\n**getLongArray**\n([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e dims)\n\nConverts a TInt32 or TInt64 Operand to a java long array \n\n##### Parameters\n\n| scope | the TensorFlow scope |\n| dims | the Operand |\n|-------|----------------------|\n\n##### Returns\n\n- the long array \n\n##### Throws\n\n| IllegalArgumentException | if the dims type is not an integer |\n|--------------------------|------------------------------------|\n\n#### public static [Shape](/jvm/api_docs/java/org/tensorflow/ndarray/Shape)\n**reduce**\n([Shape](/jvm/api_docs/java/org/tensorflow/ndarray/Shape) shape, int axis)\n\nReduces the shape by eliminating trailing Dimensions.\n\nThe last dimension, specified by axis, will be a product of all remaining dimensions\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| shape | the shape to squeeze |\n| axis | the axis to squeeze |\n|-------|----------------------|\n\n##### Returns\n\n- the new shape \n\n#### public static [Shape](/jvm/api_docs/java/org/tensorflow/ndarray/Shape)\n**toShape**\n([Scope](/jvm/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/jvm/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e dims)\n\nConverts a shape operand to a Shape object \n\n##### Parameters\n\n| scope | the TensorFlow scope |\n| dims | the Operand containing the shape values |\n|-------|-----------------------------------------|\n\n##### Returns\n\n- a new Shape based on an Operand that contains dimensions"]]