Have a question? Connect with the community at the TensorFlow Forum Visit Forum

Constant

public final class Constant

An operator producing a constant value.

All endpoints of this operator are named `constant`, except those accepting vararg elements in parameter, which are named `array`. For example:

Ops tf = Ops.create();
 tf.constant(1.0f);  // mapped to Constant.scalarOf(scope, float);
 tf.constant(new float[] {1.0f, 2.0f);  // mapped to Constant.vectorOf(scope, float[])
 tf.constant(new float[][] { {1.0f, 2.0f}, {3.0f, 4.0f} });  //mapped to Constant.tensorOf(scope, float[][])
 tf.array(1.0f, 2.0f, 3.0f);  // mapped to Constant.arrayOf(scope, float...)
 }

Constants

String OP_NAME

Public Methods

static Constant < TString >
arrayOf ( Scope scope, Charset charset, String... data)
Creates a constant of String elements, using the given charset.
static Constant < TInt32 >
arrayOf ( Scope scope, int... data)
Creates a constant of int elements.
static Constant < TInt64 >
arrayOf ( Scope scope, long... data)
Creates a constant of long elements.
static Constant < TString >
arrayOf ( Scope scope, String... data)
Creates a constant of String elements, using the default UTF-8 charset.
static Constant < TUint8 >
arrayOf ( Scope scope, byte... data)
Creates a constant of byte elements.
static Constant < TFloat32 >
arrayOf ( Scope scope, float... data)
Creates a constant of float elements.
static Constant < TBool >
arrayOf ( Scope scope, boolean... data)
Creates a constant of boolean elements.
static Constant < TFloat64 >
arrayOf ( Scope scope, double... data)
Creates a constant of double elements.
Output <T>
asOutput ()
Returns the symbolic handle of the tensor.
static <T extends TType > Constant <T>
create ( Scope scope, T tensor)
Create a constant by making an immutable copy of tensor .
static Constant < TFloat32 >
scalarOf ( Scope scope, float data)
Creates a constant containing a single float element.
static Constant < TUint8 >
scalarOf ( Scope scope, byte data)
Creates a constant containing a single byte element.
static Constant < TString >
scalarOf ( Scope scope, Charset charset, String data)
Creates a String constant using a specified encoding.
static Constant < TFloat64 >
scalarOf ( Scope scope, double data)
Creates a constant containing a single double element.
static Constant < TInt32 >
scalarOf ( Scope scope, int data)
Creates a constant containing a single int element.
static Constant < TBool >
scalarOf ( Scope scope, boolean data)
Creates a constant containing a single boolean element.
static Constant < TString >
scalarOf ( Scope scope, String data)
Creates a String constant using the default, UTF-8 encoding.
static Constant < TInt64 >
scalarOf ( Scope scope, long data)
Creates a constant containing a single long element.
static Constant < TBool >
tensorOf ( Scope scope, boolean[][][][][][] data)
Creates a rank-6 constant of boolean elements.
static Constant < TFloat64 >
tensorOf ( Scope scope, double[][][] data)
Creates a rank-3 constant of double elements.
static Constant < TString >
tensorOf ( Scope scope, String[][][][][][] data)
Creates a rank-6 constant of String elements, using default UTF-8 encoding.
static Constant < TUint8 >
tensorOf ( Scope scope, byte[][][][] data)
Creates a rank-4 constant of byte elements.
static Constant < TInt32 >
tensorOf ( Scope scope, int[][] data)
Creates a rank-2 constant of int elements.
static Constant < TInt32 >
tensorOf ( Scope scope, Shape shape, IntDataBuffer data)
Create a TInt32 constant with data from the given buffer.
static Constant < TInt64 >
tensorOf ( Scope scope, long[][] data)
Creates a rank-2 constant of long elements.
static Constant < TInt64 >
tensorOf ( Scope scope, Shape shape, LongDataBuffer data)
Create a TInt64 constant with data from the given buffer.
static Constant < TFloat32 >
tensorOf ( Scope scope, float[][][][] data)
Creates a rank-4 constant of float elements.
static Constant < TBool >
tensorOf ( Scope scope, boolean[][][] data)
Creates a rank-3 constant of boolean elements.
static Constant < TString >
tensorOf ( Scope scope, String[][][] data)
Creates a rank-3 constant of String elements, using default UTF-8 encoding.
static Constant < TInt64 >
tensorOf ( Scope scope, long[][][][][][] data)
Creates a rank-6 constant of long elements.
static Constant < TInt64 >
tensorOf ( Scope scope, long[][][][] data)
Creates a rank-4 constant of long elements.
static Constant < TInt32 >
tensorOf ( Scope scope, int[][][] data)
Creates a rank-3 constant of int elements.
static Constant < TString >
tensorOf ( Scope scope, Shape shape, DataBuffer <String> data)
Create a TString constant with data from the given buffer, using the default UTF-8 encoding.
static Constant < TBool >
tensorOf ( Scope scope, boolean[][] data)
Creates a rank-2 constant of boolean elements.
static Constant < TInt32 >
tensorOf ( Scope scope, int[][][][][] data)
Creates a rank-5 constant of int elements.
static Constant < TFloat64 >
tensorOf ( Scope scope, DoubleNdArray data)
Creates a constant of double elements that is a copy of a given n-dimensional array.
static Constant < TString >
tensorOf ( Scope scope, Charset charset, NdArray <String> data)
Creates a constant of String elements that is a copy of a given n-dimensional array, using the given encoding.
static <T extends TType > Constant <T>
tensorOf ( Scope scope, Class<T> type, Shape shape, ByteDataBuffer data)
Create a constant with data from the given buffer.
static Constant < TString >
tensorOf ( Scope scope, Charset charset, Shape shape, DataBuffer <String> data)
Create a TString constant with data from the given buffer, using the given encoding.
static Constant < TFloat64 >
tensorOf ( Scope scope, double[][][][][][] data)
Creates a rank-6 constant of double elements.
static Constant < TFloat32 >
tensorOf ( Scope scope, FloatNdArray data)
Creates a constant of float elements that is a copy of a given n-dimensional array.
static Constant < TBool >
tensorOf ( Scope scope, boolean[][][][][] data)
Creates a rank-5 constant of boolean elements.
static <T extends TNumber > Constant <T>
tensorOf ( Scope scope, Class<T> type, Number number)
Creates a scalar of type , with the value of number .
static Constant < TUint8 >
tensorOf ( Scope scope, ByteNdArray data)
Creates a constant of byte elements that is a copy of a given n-dimensional array.
static Constant < TBool >
tensorOf ( Scope scope, Shape shape, BooleanDataBuffer data)
Create a TBool constant with data from the given buffer.
static Constant < TFloat32 >
tensorOf ( Scope scope, float[][] data)
Creates a rank-2 constant of float elements.
static Constant < TUint8 >
tensorOf ( Scope scope, byte[][] data)
Creates a rank-2 constant of byte elements.
static Constant < TFloat32 >
tensorOf ( Scope scope, Shape shape, FloatDataBuffer data)
Create a TFloat32 constant with data from the given buffer.
static Constant < TBool >
tensorOf ( Scope scope, BooleanNdArray data)
Creates a constant of boolean elements that is a copy of a given n-dimensional array.
static Constant < TInt64 >
tensorOf ( Scope scope, Shape shape)
Creates a rank-1 constant of long elements representing the size of each dimensions of the given shape.
static Constant < TFloat32 >
tensorOf ( Scope scope, float[][][][][] data)
Creates a rank-5 constant of float elements.
static Constant < TUint8 >
tensorOf ( Scope scope, Shape shape, ByteDataBuffer data)
Create a TUint8 constant with data from the given buffer.
static Constant < TString >
tensorOf ( Scope scope, NdArray <String> data)
Creates a constant of String elements that is a copy of a given n-dimensional array, using the default UTF-8 encoding.
static Constant < TUint8 >
tensorOf ( Scope scope, byte[][][] data)
Creates a rank-3 constant of byte elements.
static Constant < TFloat64 >
tensorOf ( Scope scope, double[][] data)
Creates a rank-2 constant of double elements.
static Constant < TString >
tensorOf ( Scope scope, String[][] data)
Creates a rank-2 constant of String elements, using default UTF-8 encoding.
static Constant < TFloat64 >