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: TensorArray dtype is float32 but tensor has dtype undefined

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dsmilkovcommented, Feb 19, 2019

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

1reaction
nsthoratcommented, Feb 18, 2019

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

cc @dsmilkov

Read more comments on GitHub >

github_iconTop Results From Across the Web

TensorArray dtype is double but Op is trying to write dtype float ...
The problem is that lang_model returns float32 s and map_fn says it returns float64 s. One way to fix the problem is to...
Read more >
tf.TensorArray | TensorFlow v2.11.0
If the TensorArray is not dynamic, max_value=size() . value, (N+1)-D. Tensor of type dtype . The Tensor to unpack. name ...
Read more >
Advent of Code 2021 in pure TensorFlow - day 3
TensorArray . Moreover, we'll find some limitations (bug?) of the TensorArray data type and we'll write some interesting utility that's not ...
Read more >
tensorflow.python.ops.tensor_array_ops 源代码
Args: dtype: (required) data type of the TensorArray. size: (optional) int32 scalar `Tensor`: the ... TypeError: if handle is provided but is not...
Read more >
Getting Started with tfautograph
Tensor(25.0, shape=(), dtype=float32) square_if_positive(y) #> tf. ... Undefined objects throw an informative error if you attempt to access them.
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