Class LinalgOps
-
Method Summary
Modifier and TypeMethodDescriptionMultiplies matrixaby matrixb, producinga*b.Multiplies matrixaby matrixb, producinga*b.matmul(Operand<T> a, Operand<T> b, boolean transposeA, boolean transposeB, boolean adjointA, boolean adjointB, boolean aIsSparse, boolean bIsSparse) Multiplies matrixaby matrixb, producinga*b.
-
Method Details
-
matmul
Multiplies matrixaby matrixb, producinga*b.The inputs must, following any transpositions, be tensors of
rank >= 2where 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 typeTFloat16,TFloat32,TFloat64,TInt32. with arank > 1b- an Operand with same type and rank asa.- Returns:
- A Operand of the same type as
aandbwhere each inner-most matrix is the product of the corresponding matrices inaandb. This is the matrix product not an element-wise product. - Throws:
IllegalArgumentException- IftransposeAandadjointA, ortransposeBandadjointBare both set to `true`.
-
matmul
public <T extends TNumber> Operand<T> matmul(Operand<T> a, Operand<T> b, boolean transposeA, boolean transposeB) Multiplies matrixaby matrixb, producinga*b.The inputs must, following any transpositions, be tensors of
rank >= 2where 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 typeTFloat16,TFloat32,TFloat64,TInt32. with arank > 1b- an Operand with same type and rank asa.transposeA- If true,ais transposed before multiplication.transposeB- If true,bis transposed before multiplication- Returns:
- A Operand of the same type as
aandbwhere each inner-most matrix is the product of the corresponding matrices inaandb. This is the matrix product not an element-wise product. - Throws:
IllegalArgumentException- IftransposeAandadjointA, ortransposeBandadjointBare 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 matrixaby matrixb, producinga*b.The inputs must, following any transpositions, be tensors of
rank >= 2where 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 typeTFloat16,TFloat32,TFloat64,TInt32. with arank > 1b- an Operand with same type and rank asa.transposeA- If true,ais transposed before multiplication.transposeB- If True,bis transposed before multiplicationadjointA- If true,ais conjugated and transposed before multiplication.adjointB- If true,bis conjugated and transposed before multiplication.aIsSparse- If true,ais treated as a sparse matrix. Notice, this does not supportSparseTensor, it just makes optimizations that assume most values inaare zero.bIsSparse- If true,bis treated as a sparse matrix. Notice, this does not supportSparseTensor, it just makes optimizations that assume most values inbare zero.- Returns:
- A Operand of the same type as
aandbwhere each inner-most matrix is the product of the corresponding matrices inaandb. This is the matrix product not an element-wise product. - Throws:
IllegalArgumentException- IftransposeAandadjointA, ortransposeBandadjointBare both set to `true`.
-