1
let tensor1 = tf.tensor(m1);
let tensor2 = tf.tensor(m2);
console.log(tensor1.shape, tensor2.shape)
result = tf.matMul(tensor1, tensor2)

The output of shapes are => [ 6890, 3, 10 ] [ 10 ]

While trying to use matMul this is the error => Error: Error in matMul: inner shapes (10) and (undefined) of Tensors with shapes 6890,3,10 and 10 and transposeA=false and transposeB=false must match.

The same multiplication works fine in python using numpy's matmul.

1 Answer 1

1

Maybe something like this:

let tensor1 = tf.randomNormal([6890, 3, 10]);
let tensor2 = tf.randomNormal([10]).expandDims(-1);
result = tf.matMul(tensor1, tensor2).squeeze(-1)
console.log(result.shape)
[6890,3]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.