public final class Shape extends Object
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
static Shape |
make(long firstDimensionSize,
long... otherDimensionSizes)
Create a Shape representing an N-dimensional value.
|
int |
numDimensions()
Number of dimensions represented by this shape.
|
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.
|
public static Shape unknown()
public static Shape scalar()
public static Shape make(long firstDimensionSize, long... otherDimensionSizes)
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);
public int numDimensions()
public long size(int i)
Copyright © 2022. All rights reserved.