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.

"info.backend.decComplexRef is not a function" when using tfjs-models

See original GitHub issue

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): YES
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04.2 LTS
  • TensorFlow.js installed from (npm or script link): @tensorflow/tfjs-node-gpu
  • TensorFlow.js version (use command below): 3.6.1
  • Browser version: N/A (Nodejs 14)
  • Tensorflow.js Converter Version: ???

Describe the current behavior (node:2070191) UnhandledPromiseRejectionWarning: TypeError: info.backend.decComplexRef is not a function

Describe the expected behavior No errors

Standalone code to reproduce the issue

Minimal repro program (test.ts):

import * as use from '@tensorflow-models/universal-sentence-encoder';
import * as tf from '@tensorflow/tfjs-node-gpu';

async function main() {
  // Dropping this line makes the error go away, although the error is in .add below.
  const sentenceModel = await use.load();
  const model = tf.sequential();
  model.add(tf.layers.dense({
    units: 16,
    activation: 'sigmoid',
    inputShape: [3],
  }));
}
main();

package.json is generated by running these commands:

npm init
npm install --save-dev @tensorflow-models/universal-sentence-encoder @tensorflow/tfjs-node-gpu ts-node typescript

I run the main script like so:

node_modules/.bin/ts-node test.ts

Other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

(node:2070982) UnhandledPromiseRejectionWarning: TypeError: info.backend.decComplexRef is not a function
    at Engine.disposeTensor (/tmp/kk/node_modules/@tensorflow/tfjs-core/src/engine.ts:874:20)
    at Tensor.dispose (/tmp/kk/node_modules/@tensorflow/tfjs-core/src/tensor.ts:388:17)
    at Dense.Layer.addWeight (/tmp/kk/node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-layers/src/engine/topology.ts:1298:15)
    at Dense.build (/tmp/kk/node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-layers/src/layers/core.ts:244:26)
    at /tmp/kk/node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-layers/src/engine/topology.ts:993:14
    at nameScope (/tmp/kk/node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-layers/src/common.ts:48:20)
    at Dense.Layer.apply (/tmp/kk/node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-layers/src/engine/topology.ts:979:12)
    at Sequential.add (/tmp/kk/node_modules/@tensorflow/tfjs/node_modules/@tensorflow/tfjs-layers/src/models.ts:478:15)
    at /tmp/kk/test.ts:8:9
    at step (/tmp/kk/test.ts:33:23)

Note: If I drop the line initializing the universal sentence encoder, the error disappears.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
outermeasurecommented, May 23, 2021

I could also reproduce this bug when using node v14, npm v7.14 and the following deps in package.json:

"devDependencies": {
    "@tensorflow-models/universal-sentence-encoder": "^1.3.2",
    "@tensorflow/tfjs": "3.6.0",
    "ts-node": "^9.1.1",
    "typescript": "^4.2.4"
  }

It wasn’t reproducible with npm v6.

0reactions
rubenlgcommented, Jun 3, 2021

I can confirm this resolved the issue. Thanks everyone!

Read more comments on GitHub >

github_iconTop Results From Across the Web

info.backend.decComplexRef is not a function · Issue #4609 ...
Try to run wasm backend on bidirectional GRU. Wasm won't create the model. import * as tf from '@tensorflow/tfjs ...
Read more >
Platform and environment | TensorFlow.js
Here are a few useful things to know when using this backend: \ ... Tensor s that are not returned by a function...
Read more >
Model.predict() not a function - Google Groups
I am trying to do image segementation of cell images to identify cells in tensor flow using data provided in ...
Read more >
i.detect is not a function when tried to use cocoSSD model in ...
I am trying to use the coco SSD model to detect the object in a given image. I have imported the required libraries...
Read more >
@tensorflow/tfjs - npm
Use flexible and intuitive APIs to build models from scratch using the low-level JavaScript linear algebra library or the high-level layers API.
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