Class Orthogonal<T extends TFloating>

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

public class Orthogonal<T extends TFloating> extends BaseInitializer<T>
Initializer that generates an orthogonal matrix.

If the shape of the tensor to initialize is two-dimensional, it is initialized with an orthogonal matrix obtained from the QR decomposition of a matrix of random numbers drawn from a normal distribution. If the matrix has fewer rows than columns then the output will have orthogonal rows. Otherwise, the output will have orthogonal columns.

If the shape of the tensor to initialize is more than two-dimensional, a matrix of shape (shape.size(0) * ... * shape.size(n - 2), shape.size(n - 1)) is initialized, where n is the length of the shape vector. The matrix is subsequently reshaped to give a tensor of the desired shape.

Examples:

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

  • Constructor Details

    • Orthogonal

      public Orthogonal(long seed)
      Creates an Orthogonal Initializer using GAIN_DEFAULT for the gain.
      Parameters:
      seed - the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and dtype.
    • Orthogonal

      public Orthogonal(double gain, long seed)
      Creates an Orthogonal Initializer
      Parameters:
      gain - the gain to be applied to the Matrix.
      seed - the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and dtype.
  • 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.