Warning: This API is deprecated and will be removed in a future
version of TensorFlow after
the replacement is stable.
Shape
Stay organized with collections
Save and categorize content based on your preferences.
The possibly partially known shape of a tensor produced by an operation.
Public Methods
boolean
|
|
int
|
|
static
Shape
|
make(long firstDimensionSize, long... otherDimensionSizes)
Create a Shape representing an N-dimensional value.
|
int
|
|
static
Shape
|
scalar()
Create a Shape representing a scalar value.
|
long
|
size(int i)
The size of the i-th dimension.
|
String
|
toString()
Succinct description of the shape meant for debugging.
|
static
Shape
|
unknown()
Create a Shape representing an unknown number of dimensions.
|
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
boolean
equals
(Object obj)
public
static
Shape
make
(long firstDimensionSize, long... otherDimensionSizes)
Create a Shape representing an N-dimensional value.
Creates a Shape representing an N-dimensional value (N being at least 1), with the provided
size for each dimension. A -1 indicates that the size of the corresponding dimension is
unknown. For example:
// A 2-element vector.
Shape vector = Shape.create(2);
// A 2x3 matrix.
Shape matrix = Shape.create(2, 3);
// A matrix with 4 columns but an unknown number of rows.
// This is typically used to indicate the shape of tensors that represent
// a variable-sized batch of values. The Shape below might represent a
// variable-sized batch of 4-element vectors.
Shape batch = Shape.create(-1, 4);
Parameters
firstDimensionSize |
|
otherDimensionSizes |
|
public
int
numDimensions
()
Number of dimensions represented by this shape.
Returns
- -1 if the number of dimensions is unknown, 0 if the shape represents a scalar, 1 for a
vector, 2 for a matrix etc.
public
static
Shape
scalar
()
Create a Shape representing a scalar value.
public
long
size
(int i)
The size of the i-th dimension.
Returns
- The size of the requested dimension or -1 if it is unknown.
public
String
toString
()
Succinct description of the shape meant for debugging.
public
static
Shape
unknown
()
Create a Shape representing an unknown number of 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 2022-02-12 UTC.
[null,null,["Last updated 2022-02-12 UTC."],[],[],null,["# Shape\n\npublic final class **Shape** \nThe possibly partially known shape of a tensor produced by an operation. \n\n### Public Methods\n\n|-----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| boolean | [equals](/api_docs/java/org/tensorflow/Shape#equals(java.lang.Object))(Object obj) |\n| int | [hashCode](/api_docs/java/org/tensorflow/Shape#hashCode())() |\n| static [Shape](/api_docs/java/org/tensorflow/Shape) | [make](/api_docs/java/org/tensorflow/Shape#make(long,%20long...))(long firstDimensionSize, long... otherDimensionSizes) Create a Shape representing an N-dimensional value. |\n| int | [numDimensions](/api_docs/java/org/tensorflow/Shape#numDimensions())() Number of dimensions represented by this shape. |\n| static [Shape](/api_docs/java/org/tensorflow/Shape) | [scalar](/api_docs/java/org/tensorflow/Shape#scalar())() Create a Shape representing a scalar value. |\n| long | [size](/api_docs/java/org/tensorflow/Shape#size(int))(int i) The size of the i-th dimension. |\n| String | [toString](/api_docs/java/org/tensorflow/Shape#toString())() Succinct description of the shape meant for debugging. |\n| static [Shape](/api_docs/java/org/tensorflow/Shape) | [unknown](/api_docs/java/org/tensorflow/Shape#unknown())() Create a Shape representing an unknown number of dimensions. |\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 Methods\n--------------\n\n#### public boolean\n**equals**\n(Object obj)\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| obj | |\n|-----|---|\n\n#### public int\n**hashCode**\n()\n\n\u003cbr /\u003e\n\n#### public static [Shape](/api_docs/java/org/tensorflow/Shape)\n**make**\n(long firstDimensionSize, long... otherDimensionSizes)\n\nCreate a Shape representing an N-dimensional value.\n\nCreates a Shape representing an N-dimensional value (N being at least 1), with the provided\nsize for each dimension. A -1 indicates that the size of the corresponding dimension is\nunknown. For example:\n\n // A 2-element vector.\n Shape vector = Shape.create(2);\n\n // A 2x3 matrix.\n Shape matrix = Shape.create(2, 3);\n\n // A matrix with 4 columns but an unknown number of rows.\n // This is typically used to indicate the shape of tensors that represent\n // a variable-sized batch of values. The Shape below might represent a\n // variable-sized batch of 4-element vectors.\n Shape batch = Shape.create(-1, 4);\n \n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| firstDimensionSize | |\n| otherDimensionSizes | |\n|---------------------|---|\n\n#### public int\n**numDimensions**\n()\n\nNumber of dimensions represented by this shape. \n\n##### Returns\n\n- -1 if the number of dimensions is unknown, 0 if the shape represents a scalar, 1 for a vector, 2 for a matrix etc. \n\n#### public static [Shape](/api_docs/java/org/tensorflow/Shape)\n**scalar**\n()\n\nCreate a Shape representing a scalar value. \n\n#### public long\n**size**\n(int i)\n\nThe size of the i-th dimension. \n\n##### Parameters\n\n| i | |\n|---|---|\n\n##### Returns\n\n- The size of the requested dimension or -1 if it is unknown. \n\n#### public String\n**toString**\n()\n\nSuccinct description of the shape meant for debugging. \n\n#### public static [Shape](/api_docs/java/org/tensorflow/Shape)\n**unknown**\n()\n\nCreate a Shape representing an unknown number of dimensions."]]