How to solve having different ranks of tensor?

Viewed 224

I have a tensorflow.js model and I have created dummy input for my model which is:

 a=tf.tensor2d([1,2,3,4,5,6,7,8],[8,1],dtype="int32")

And I have input it into my model using the following line:

model.then(m => m.executeAsync({"input_ids":a,"attention_mask":a,"token_type_ids":a}))

Three of the inputs are having the same value, but I am getting the following error message:

Uncaught (in promise) Error: Error in matMul: inputs must have the same rank of at least 2, got ranks 3 and 2

Does anyone know what I did wrong and caused there are rank 3 tensors in my input? Thank you.

1 Answers

Things you can do:

  1. Check the input dimension of your model
  2. Reshape the input tensor dimension to the expected dimension by the model
  3. Then inference
Related