@Operator public final class Constant<T> extends PrimitiveOp implements Operand<T>
operation
Modifier and Type | Method and Description |
---|---|
Output<T> |
asOutput()
Returns the symbolic handle of a tensor.
|
static Constant<Boolean> |
create(Scope scope,
boolean data)
Creates a constant containing a single
boolean element. |
static Constant<Boolean> |
create(Scope scope,
boolean[] data)
Creates a rank-1 constant of
boolean elements. |
static Constant<Boolean> |
create(Scope scope,
boolean[][] data)
Creates a rank-2 constant of
boolean elements. |
static Constant<Boolean> |
create(Scope scope,
boolean[][][] data)
Creates a rank-3 constant of
boolean elements. |
static Constant<Boolean> |
create(Scope scope,
boolean[][][][] data)
Creates a rank-4 constant of
boolean elements. |
static Constant<Boolean> |
create(Scope scope,
boolean[][][][][] data)
Creates a rank-5 constant of
boolean elements. |
static Constant<Boolean> |
create(Scope scope,
boolean[][][][][][] data)
Creates a rank-6 constant of
boolean elements. |
static Constant<String> |
create(Scope scope,
byte[] data)
Creates a constant containing a single
String element, represented as an array of byte s. |
static Constant<String> |
create(Scope scope,
byte[][] data)
Creates a rank-1 constant of
String elements, each represented as an array of byte s. |
static Constant<String> |
create(Scope scope,
byte[][][] data)
Creates a rank-2 constant of
String elements, each represented as an array of byte s. |
static Constant<String> |
create(Scope scope,
byte[][][][] data)
Creates a rank-3 constant of
String elements, each represented as an array of byte s. |
static Constant<String> |
create(Scope scope,
byte[][][][][] data)
Creates a rank-4 constant of
String elements, each represented as an array of byte s. |
static Constant<String> |
create(Scope scope,
byte[][][][][][] data)
Creates a rank-5 constant of
String elements, each represented as an array of byte s. |
static <T> Constant<T> |
create(Scope scope,
Class<T> type,
long[] shape,
ByteBuffer data)
Create a constant with data from the given buffer.
|
static Constant<Double> |
create(Scope scope,
double data)
Creates a constant containing a single
double element. |
static Constant<Double> |
create(Scope scope,
double[] data)
Creates a rank-1 constant of
double elements. |
static Constant<Double> |
create(Scope scope,
double[][] data)
Creates a rank-2 constant of
double elements. |
static Constant<Double> |
create(Scope scope,
double[][][] data)
Creates a rank-3 constant of
double elements. |
static Constant<Double> |
create(Scope scope,
double[][][][] data)
Creates a rank-4 constant of
double elements. |
static Constant<Double> |
create(Scope scope,
double[][][][][] data)
Creates a rank-5 constant of
double elements. |
static Constant<Double> |
create(Scope scope,
double[][][][][][] data)
Creates a rank-6 constant of
double elements. |
static Constant<Float> |
create(Scope scope,
float data)
Creates a constant containing a single
float element. |
static Constant<Float> |
create(Scope scope,
float[] data)
Creates a rank-1 constant of
float elements. |
static Constant<Float> |
create(Scope scope,
float[][] data)
Creates a rank-2 constant of
float elements. |
static Constant<Float> |
create(Scope scope,
float[][][] data)
Creates a rank-3 constant of
float elements. |
static Constant<Float> |
create(Scope scope,
float[][][][] data)
Creates a rank-4 constant of
float elements. |
static Constant<Float> |
create(Scope scope,
float[][][][][] data)
Creates a rank-5 constant of
float elements. |
static Constant<Float> |
create(Scope scope,
float[][][][][][] data)
Creates a rank-6 constant of
float elements. |
static Constant<Integer> |
create(Scope scope,
int data)
Creates a constant containing a single
int element. |
static Constant<Integer> |
create(Scope scope,
int[] data)
Creates a rank-1 constant of
int elements. |
static Constant<Integer> |
create(Scope scope,
int[][] data)
Creates a rank-2 constant of
int elements. |
static Constant<Integer> |
create(Scope scope,
int[][][] data)
Creates a rank-3 constant of
int elements. |
static Constant<Integer> |
create(Scope scope,
int[][][][] data)
Creates a rank-4 constant of
int elements. |
static Constant<Integer> |
create(Scope scope,
int[][][][][] data)
Creates a rank-5 constant of
int elements. |
static Constant<Integer> |
create(Scope scope,
int[][][][][][] data)
Creates a rank-6 constant of
int elements. |
static Constant<Long> |
create(Scope scope,
long data)
Creates a constant containing a single
long element. |
static Constant<Long> |
create(Scope scope,
long[] data)
Creates a rank-1 constant of
long elements. |
static Constant<Long> |
create(Scope scope,
long[][] data)
Creates a rank-2 constant of
long elements. |
static Constant<Long> |
create(Scope scope,
long[][][] data)
Creates a rank-3 constant of
long elements. |
static Constant<Long> |
create(Scope scope,
long[][][][] data)
Creates a rank-4 constant of
long elements. |
static Constant<Long> |
create(Scope scope,
long[][][][][] data)
Creates a rank-5 constant of
long elements. |
static Constant<Long> |
create(Scope scope,
long[][][][][][] data)
Creates a rank-6 constant of
long elements. |
static Constant<Double> |
create(Scope scope,
long[] shape,
DoubleBuffer data)
Create a
DataType.DOUBLE constant with data from the given buffer. |
static Constant<Float> |
create(Scope scope,
long[] shape,
FloatBuffer data)
Create a
DataType.FLOAT constant with data from the given buffer. |
static Constant<Integer> |
create(Scope scope,
long[] shape,
IntBuffer data)
Create a
DataType.INT32 constant with data from the given buffer. |
static Constant<Long> |
create(Scope scope,
long[] shape,
LongBuffer data)
Create a
DataType.INT64 constant with data from the given buffer. |
static <T> Constant<T> |
create(Scope scope,
Object object,
Class<T> type)
Create a constant from a Java object.
|
static Constant<String> |
create(Scope scope,
String data)
Creates a
String constant using the default, UTF-8 encoding. |
static Constant<String> |
create(Scope scope,
String data,
Charset charset)
Creates a
String constant using a specified encoding. |
equals, hashCode, op, toString
public static Constant<Integer> create(Scope scope, int data)
int
element.scope
- is a scope used to add the underlying operation.data
- The value to put into the new constant.public static Constant<Integer> create(Scope scope, int[] data)
int
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Integer> create(Scope scope, int[][] data)
int
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Integer> create(Scope scope, int[][][] data)
int
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Integer> create(Scope scope, int[][][][] data)
int
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Integer> create(Scope scope, int[][][][][] data)
int
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Integer> create(Scope scope, int[][][][][][] data)
int
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Integer> create(Scope scope, long[] shape, IntBuffer data)
DataType.INT32
constant with data from the given buffer.
Creates a constant with the given shape by copying elements from the buffer (starting from
its current position) into the tensor. For example, if shape = {2,3}
(which represents
a 2x3 matrix) then the buffer must have 6 elements remaining, which will be consumed by this
method.
scope
- is a scope used to add the underlying operation.shape
- the tensor shape.data
- a buffer containing the tensor data.IllegalArgumentException
- If the tensor shape is not compatible with the bufferpublic static Constant<Float> create(Scope scope, float data)
float
element.scope
- is a scope used to add the underlying operation.data
- The value to put into the new constant.public static Constant<Float> create(Scope scope, float[] data)
float
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Float> create(Scope scope, float[][] data)
float
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Float> create(Scope scope, float[][][] data)
float
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Float> create(Scope scope, float[][][][] data)
float
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Float> create(Scope scope, float[][][][][] data)
float
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Float> create(Scope scope, float[][][][][][] data)
float
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Float> create(Scope scope, long[] shape, FloatBuffer data)
DataType.FLOAT
constant with data from the given buffer.
Creates a constant with the given shape by copying elements from the buffer (starting from
its current position) into the tensor. For example, if shape = {2,3}
(which represents
a 2x3 matrix) then the buffer must have 6 elements remaining, which will be consumed by this
method.
scope
- is a scope used to add the underlying operation.shape
- the tensor shape.data
- a buffer containing the tensor data.IllegalArgumentException
- If the tensor shape is not compatible with the bufferpublic static Constant<Double> create(Scope scope, double data)
double
element.scope
- is a scope used to add the underlying operation.data
- The value to put into the new constant.public static Constant<Double> create(Scope scope, double[] data)
double
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Double> create(Scope scope, double[][] data)
double
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Double> create(Scope scope, double[][][] data)
double
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Double> create(Scope scope, double[][][][] data)
double
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Double> create(Scope scope, double[][][][][] data)
double
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Double> create(Scope scope, double[][][][][][] data)
double
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Double> create(Scope scope, long[] shape, DoubleBuffer data)
DataType.DOUBLE
constant with data from the given buffer.
Creates a constant with the given shape by copying elements from the buffer (starting from
its current position) into the tensor. For example, if shape = {2,3}
(which represents
a 2x3 matrix) then the buffer must have 6 elements remaining, which will be consumed by this
method.
scope
- is a scope used to add the underlying operation.shape
- the tensor shape.data
- a buffer containing the tensor data.IllegalArgumentException
- If the tensor shape is not compatible with the bufferpublic static Constant<Long> create(Scope scope, long data)
long
element.scope
- is a scope used to add the underlying operation.data
- The value to put into the new constant.public static Constant<Long> create(Scope scope, long[] data)
long
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Long> create(Scope scope, long[][] data)
long
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Long> create(Scope scope, long[][][] data)
long
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Long> create(Scope scope, long[][][][] data)
long
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Long> create(Scope scope, long[][][][][] data)
long
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Long> create(Scope scope, long[][][][][][] data)
long
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Long> create(Scope scope, long[] shape, LongBuffer data)
DataType.INT64
constant with data from the given buffer.
Creates a constant with the given shape by copying elements from the buffer (starting from
its current position) into the tensor. For example, if shape = {2,3}
(which represents
a 2x3 matrix) then the buffer must have 6 elements remaining, which will be consumed by this
method.
scope
- is a scope used to add the underlying operation.shape
- the tensor shape.data
- a buffer containing the tensor data.IllegalArgumentException
- If the tensor shape is not compatible with the bufferpublic static Constant<Boolean> create(Scope scope, boolean data)
boolean
element.scope
- is a scope used to add the underlying operation.data
- The value to put into the new constant.public static Constant<Boolean> create(Scope scope, boolean[] data)
boolean
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Boolean> create(Scope scope, boolean[][] data)
boolean
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Boolean> create(Scope scope, boolean[][][] data)
boolean
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Boolean> create(Scope scope, boolean[][][][] data)
boolean
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Boolean> create(Scope scope, boolean[][][][][] data)
boolean
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<Boolean> create(Scope scope, boolean[][][][][][] data)
boolean
elements.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. The dimensions of the
new constant will match those of the array.public static Constant<String> create(Scope scope, String data)
String
constant using the default, UTF-8 encoding.scope
- is a scope used to add the underlying operation.data
- The string to put into the new constant.public static Constant<String> create(Scope scope, String data, Charset charset)
String
constant using a specified encoding.scope
- is a scope used to add the underlying operation.charset
- The encoding from String to bytes.data
- The string to put into the new constant.public static Constant<String> create(Scope scope, byte[] data)
String
element, represented as an array of byte
s.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. String elements are
sequences of bytes from the last array dimension.public static Constant<String> create(Scope scope, byte[][] data)
String
elements, each represented as an array of byte
s.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. String elements are
sequences of bytes from the last array dimension.public static Constant<String> create(Scope scope, byte[][][] data)
String
elements, each represented as an array of byte
s.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. String elements are
sequences of bytes from the last array dimension.public static Constant<String> create(Scope scope, byte[][][][] data)
String
elements, each represented as an array of byte
s.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. String elements are
sequences of bytes from the last array dimension.public static Constant<String> create(Scope scope, byte[][][][][] data)
String
elements, each represented as an array of byte
s.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. String elements are
sequences of bytes from the last array dimension.public static Constant<String> create(Scope scope, byte[][][][][][] data)
String
elements, each represented as an array of byte
s.scope
- is a scope used to add the underlying operation.data
- An array containing the values to put into the new constant. String elements are
sequences of bytes from the last array dimension.public static <T> Constant<T> create(Scope scope, Class<T> type, long[] shape, ByteBuffer data)
Creates a Constant with the provided shape of any type where the constant data has been
encoded into data
as per the specification of the TensorFlow C
API.
scope
- is a scope used to add the underlying operation.type
- the tensor datatype.shape
- the tensor shape.data
- a buffer containing the tensor data.IllegalArgumentException
- If the tensor datatype or shape is not compatible with the
bufferpublic static <T> Constant<T> create(Scope scope, Object object, Class<T> type)
The argument object
is first converted into a Tensor using Tensor.create(Object)
, so only Objects supported by this method must be
provided. For example:
Constant.create(scope, new int[]{{1, 2}, {3, 4}}, Integer.class); // returns a 2x2 integer matrix
scope
- is a scope used to add the underlying operation.object
- a Java object representing the constant.Tensor.create
public Output<T> asOutput()
Operand
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.
asOutput
in interface Operand<T>
OperationBuilder.addInput(Output)
Copyright © 2022. All rights reserved.