tfjs: Error: TensorArray dtype is float32 but tensor has dtype undefined

To get help from the community, check out our Google group.

TensorFlow.js version

tensorflowjs 0.5.6

Dependency versions:
  keras 2.1.6
  tensorflow 1.9.0

Browser version

Mac + Chrome 68.0.3440.84 64bit (Latest version)

Describe the problem or feature request

With the latest version of tfjs,  I can  succssfully converte 
ssd_mobilenet_v1_coco_2018_01_28 to web model and load it. 
(This is the Object Detection model)
But when I try to run model.executeAsync(), 
the error as below happened.

tf-converter.esm.js?:formatted:6254 Uncaught (in promise) Error: TensorArray dtype is float32 but tensor has dtype undefined
    at e.scatter (tf-converter.esm.js?:formatted:6254)
    at eval (tf-converter.esm.js?:formatted:6388)
    at eval (tf-converter.esm.js?:formatted:144)
    at Object.eval [as next] (tf-converter.esm.js?:formatted:157)
    at eval (tf-converter.esm.js?:formatted:64)
    at new Promise (<anonymous>)
    at __awaiter (tf-converter.esm.js?:formatted:43)
    at executeOp$2 (tf-converter.esm.js?:formatted:6295)
    at executeOp$15 (tf-converter.esm.js?:formatted:6772)
    at eval (tf-converter.esm.js?:formatted:7070)

Code to reproduce the bug / link to feature request

The reproduce procedure is simple.
1. converte ssd_mobilenet_v1_coco_2018_01_28
2. load and run executeAsync()
 
My code is as below, it's written by React JSX:

 componentDidMount = async () => {
    this.model = new Model()
    await this.model.load()
    const tensor = tf.fromPixels(this.image).toFloat().expandDims(0)
    this.model.model.executeAsync({
      image_tensor: tensor,
    }).then((result) => {
     // TODO
    })
  }

@dsmilkov

I tried to read the sourcecode and find the error may happened in 
tfjs-converter/src/executor/tensor_array.ts
  scatter(indices: number[], tensor: Tensor) {
    if (tensor.dtype !== this.dtype) {
      throw new Error(`TensorArray dtype is ${
          this.dtype} but tensor has dtype ${tensor.dtype}`);
    }
    // something else......
  }

I set the breakpoint here and find the input parameter 'tensor' is not ts.Tensor but the Array.
So tensor.dtype is undefined.
Is this caused by my misuse or bugs? 
Please help, thanks.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @Naikno, the fix is in and we are going to release TF.js 0.15.3, which will happen by end of week (most likely Friday). At the same time, we will release new coco-ssd that depends on the 0.15.3. In the mean time, you have two options: use older version (0.14.1), or use the latest alpha release 1.0.0-alpha3

Thanks, we’ll take a look ASAP. For now can you use 0.14.1?

cc @dsmilkov

I found this error with version 0.15.1 instead it works with 0.14.0