Class LinalgOps

java.lang.Object
org.tensorflow.framework.op.LinalgOps

public class LinalgOps extends Object
  • Method Details

    • matmul

      public <T extends TNumber> Operand<T> matmul(Operand<T> a, Operand<T> b)
      Multiplies matrix a by matrix b, producing a * b .

      The inputs must, following any transpositions, be tensors of rank >= 2 where the inner 2 dimensions specify valid matrix multiplication dimensions, and any further outer dimensions specify matching batch size.

      Both matrices must be of the same type. The supported types are: TFloat16, TFloat32, TFloat64, TInt32.

      Either matrix can be transposed or adjointed (conjugated and transposed) on the fly by setting one of the corresponding flag to true. These are false by default.

      A simple 2-D tensor matrix multiplication:

      Operand<TFloat64> a = tf.constant(new double[][] {
              {-8.944851},
              {4.1711287},
              {-0.22380222}
          });
      Operand<TFloat64> b = tf.constant( new double[][] {
              {-14.276086, -12.433481, -2.2447076, -1.5775859, 1.8588694}
          });
      Operand<TFloat64> result = fops.linalg.matmul(a, b);
      // result = {
      //     {127.69746,  111.21564,  20.078575,  14.111271,  -16.62731},
      //     {-59.547394, -51.861652, -9.362965,  -6.580314,    7.753584},
      //     {  3.1950197,  2.7826407, 0.50237054, 0.35306725, -0.4160191}
      //  }
      
      

      Note: This is matrix product, not element-wise product.

      Type Parameters:
      T - the data type of the Operands
      Parameters:
      a - an Operand of of type TFloat16, TFloat32, TFloat64 , TInt32. with a rank > 1
      b - an Operand with same type and rank as a.
      Returns:
      A Operand of the same type as a and b where each inner-most matrix is the product of the corresponding matrices in a and b. This is the matrix product not an element-wise product.
      Throws:
      IllegalArgumentException - If transposeA and adjointA , or transposeB and adjointB are both set to `true`.
    • matmul

      public <T extends TNumber> Operand<T> matmul(Operand<T> a, Operand<T> b, boolean transposeA, boolean transposeB)
      Multiplies matrix a by matrix b, producing a * b .

      The inputs must, following any transpositions, be tensors of rank >= 2 where the inner 2 dimensions specify valid matrix multiplication dimensions, and any further outer dimensions specify matching batch size.

      Both matrices must be of the same type. The supported types are: TFloat16, TFloat32, TFloat64, TInt32.

      Either matrix can be transposed or adjointed (conjugated and transposed) on the fly by setting one of the corresponding flag to true. These are false by default.

      Note: This is matrix product, not element-wise product.

      A simple 2-D tensor matrix multiplication:

      Operand<TFloat64> a = tf.constant(new double[][] {
              {-8.944851},
              {4.1711287},
              {-0.22380222}
          });
      Operand<TFloat64> b = tf.constant( new double[][] {
              {-14.276086, -12.433481, -2.2447076, -1.5775859, 1.8588694}
          });
      Operand<TFloat64> result = fops.linalg.matmul(a, b);
      // result = {
      //     {127.69746,  111.21564,  20.078575,  14.111271,  -16.62731},
      //     {-59.547394, -51.861652, -9.362965,  -6.580314,    7.753584},
      //     {  3.1950197,  2.7826407, 0.50237054, 0.35306725, -0.4160191}
      //  }
      
      
      Type Parameters:
      T - the data type of the Operands
      Parameters:
      a - an Operand of of type TFloat16, TFloat32, TFloat64 , TInt32. with a rank > 1
      b - an Operand with same type and rank as a.
      transposeA - If true, a is transposed before multiplication.
      transposeB - If true, b is transposed before multiplication
      Returns:
      A Operand of the same type as a and b where each inner-most matrix is the product of the corresponding matrices in a and b. This is the matrix product not an element-wise product.
      Throws:
      IllegalArgumentException - If transposeA and adjointA , or transposeB and adjointB are both set to `true`.
    • matmul

      public <T extends TNumber> Operand<T> matmul(Operand<T> a, Operand<T> b, boolean transposeA, boolean transposeB, boolean adjointA, boolean adjointB, boolean aIsSparse, boolean bIsSparse)
      Multiplies matrix a by matrix b, producing a * b .

      The inputs must, following any transpositions, be tensors of rank >= 2 where the inner 2 dimensions specify valid matrix multiplication dimensions, and any further outer dimensions specify matching batch size.

      Both matrices must be of the same type. The supported types are: TFloat16, TFloat32, TFloat64, TInt32.

      Either matrix can be transposed or adjointed (conjugated and transposed) on the fly by setting one of the corresponding flag to true. These are false by default.

      Note: This is matrix product, not element-wise product.

      A simple 2-D tensor matrix multiplication:

      Operand<TFloat64> a = tf.constant(new double[][] {
              {-8.944851},
              {4.1711287},
              {-0.22380222}
          });
      Operand<TFloat64> b = tf.constant( new double[][] {
              {-14.276086, -12.433481, -2.2447076, -1.5775859, 1.8588694}
          });
      Operand<TFloat64> result = fops.linalg.matmul(a, b);
      // result = {
      //     {127.69746,  111.21564,  20.078575,  14.111271,  -16.62731},
      //     {-59.547394, -51.861652, -9.362965,  -6.580314,    7.753584},
      //     {  3.1950197,  2.7826407, 0.50237054, 0.35306725, -0.4160191}
      //  }
      
      
      Type Parameters:
      T - the data type of the Operands
      Parameters:
      a - an Operand of of type TFloat16, TFloat32, TFloat64 , TInt32. with a rank > 1
      b - an Operand with same type and rank as a.
      transposeA - If true, a is transposed before multiplication.
      transposeB - If True, b is transposed before multiplication
      adjointA - If true, a is conjugated and transposed before multiplication.
      adjointB - If true, b is conjugated and transposed before multiplication.
      aIsSparse - If true, a is treated as a sparse matrix. Notice, this does not support SparseTensor, it just makes optimizations that assume most values in a are zero.
      bIsSparse - If true, b is treated as a sparse matrix. Notice, this does not support SparseTensor, it just makes optimizations that assume most values in b are zero.
      Returns:
      A Operand of the same type as a and b where each inner-most matrix is the product of the corresponding matrices in a and b. This is the matrix product not an element-wise product.
      Throws:
      IllegalArgumentException - If transposeA and adjointA , or transposeB and adjointB are both set to `true`.