question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: TensorList shape mismatch: Shapes -1 and 3 must match

See original GitHub issue

System information

  • I’m trying to convert a TF Object Detection model to SavedModel and then TF.js without any customization
  • I’m working on Colab to export the model and I load the converted model on Chrome.
  • Chrome version 88.0.4324.146 (Official Build) (64-bit)
  • TensorFlow.js installed from yarn
  • tfjs-core: ^3.0.0
  • tfjs-converter: ^3.0.0
  • TF 2.4.1
  • Python 3.6.9

I’m currently trying to convert to TF.js one of the Object Detection models from the TF2 OD ZOO, in particular SSD MobileNet V2 FPNLite 320x320.

When I convert the model pre-existing SavedModel to TF.js from the saved_model folder I’m able to import it in my browser and launch it through executeAsync(). If I keep the original pipeline.config and try to create another SavedModel from the provided checkpoint using this line

python exporter_main_v2.py --input_type image_tensor \
    --pipeline_config_path ./pre-trained-models/ssd320/pipeline.config \
    --trained_checkpoint_dir ./pre-trained-models/ssd320/checkpoint_0 \
    --output_directory ./pre-trained-models/ssd320/exported_model

after I convert it to TF.js with the following line

tensorflowjs_converter \
    --input_format=tf_saved_model \
    --saved_model_tags=serve \
    ./pre-trained-models/ssd320/path-to-savedmodel-folder \
    ./pre-trained-models/tfjs_test

I encounter the following error when I try to launch the inference on my browser

util_base.js?a6b2:141 Uncaught (in promise) Error: TensorList shape mismatch:  Shapes -1 and 3 must match
    at Module.assert (util_base.js?a6b2:141)
    at assertShapesMatchAllowUndefinedSize (tensor_utils.js?74aa:24)
    at TensorList.setItem (tensor_list.js?41f7:182)
    at Module.executeOp (control_executor.js?de9e:188)
    at eval (operation_executor.js?be85:52)
    at executeOp (operation_executor.js?be85:94)
    at GraphExecutor.processStack (graph_executor.js?33ef:390)
    at GraphExecutor.executeWithControlFlow (graph_executor.js?33ef:350)
    at async GraphExecutor._executeAsync (graph_executor.js?33ef:285)
    at async GraphModel.executeAsync (graph_model.js?9724:316)

I tried with SSD MobileNet v2 320x320 (no FPN here) and the outcome is the same. I’m starting to think that it may be connected to the use of exporter_main_v2.py but I wouldn’t know how to convert the model without it.

Could you please help me figure out something more about the cause of this issue?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:16

github_iconTop GitHub Comments

6reactions
nirchetritcommented, Feb 15, 2021

I have the same exact error when training the model using the object detection API. all works fine right to the point where I convert the model to TFJS. after loading an image I got the error: TensorList shape mismatch: Shapes -1 and 3 must match

4reactions
umitkacarcommented, Feb 15, 2021

I’ve been working for a week. This error appears to be from open source applications that were not in previous versions. I even tried from old models. They are working. But the one I just created doesn’t work.

This error continues. How do we fix this?

tfjs-core: ^3.0.0
tfjs-converter: ^3.0.0
TF 2.4.1
Python 3.6.9
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: TensorList shape mismatch: Shapes -1 and 3 must ...
I've been working for a week. This error appears to be from open source applications that were not in previous versions.
Read more >
Uncaught (in promise) Error: TensorList shape mismatch
I find it curious that the error states Shapes -1 and must match. ... -1 and what? I'm not entirely sure what tf...
Read more >
Getting a shape error in the Dense Layer - TensorFlow Forum
The shape mismatch error refers to the fact that your model has 4 output values from the last dense layer but labels represent...
Read more >
Shape mismatch issue with tf.js - tips? : r/tensorflow - Reddit
No matter how I change the parameters of the layers, I get the following error message: "Error: Error when checking target: expected ...
Read more >
tensorflow/python/ops/parallel_for/pfor.py - platform/external ...
make this an error instead of assuming TensorLists have handle data. ... We vectorize this since we need to change the element shape...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found