@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 <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,
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.
|
equals, hashCode, toStringpublic 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, 7); // returns a constant scalar tensor 7
scope - is a scope used to add the underlying operation.object - a Java object representing the constant.Tensor.createpublic 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, 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, 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[] 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 <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 Output<T> asOutput()
OperandInputs 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 © 2015–2018. All rights reserved.