Class Constant<T extends TType>

java.lang.Object
org.tensorflow.framework.initializers.BaseInitializer<T>
org.tensorflow.framework.initializers.Constant<T>
Type Parameters:
T - The Type for the call operation
All Implemented Interfaces:
Initializer<T>

public class Constant<T extends TType> extends BaseInitializer<T>
Initializer that generates tensors with a constant value.

Examples:

     Constant<TFloat32> initializer =
             new org.tensorflow.framework.initializers.Constant<>(tf, 3f);
     Operand<TFloat32> values =
             initializer.call(Ops tf, tf.constant(Shape.of(2,2)), TFloat32.class);
  • Constructor Details

    • Constant

      public Constant(long value)
      Creates an Initializer that generates tensors with a constant value.
      Parameters:
      value - a long value used for the constant.
    • Constant

      public Constant(double value)
      Creates an Initializer that generates tensors with a constant value.
      Parameters:
      value - a double value used for the constant.
    • Constant

      public Constant(boolean value)
      Creates an Initializer that generates tensors with a constant value.
      Parameters:
      value - a boolean value used for the constant.
  • Method Details

    • call

      public Operand<T> call(Ops tf, Operand<TInt64> dims, Class<T> type)
      Generates the operation used to perform the initialization.
      Parameters:
      tf - the TensorFlow Ops
      dims - the shape dimensions
      type - the type of tensor
      Returns:
      An operand for the initialization.