Meng Lee
Meng Lee

Reputation: 123

Can't predict using loaded FrozenModel

I copied the code from tfjs-examples/mobilenet/ and try to run my own frozen model, the model was loaded, but producing error when I try to use predict method.

I'm using tfjs of version 0.14.2 and Google Chrome, version 71.0.3578.98

I used the mobilenet example shown in tfjs-examples repo and started the server by yarn watch.

Secondly, I loaded my own FrozenModel successfully.

But when I use the predict method of the loaded model with a input of correct shape, it shown the error below:

image

ERROR: 0:163: 'updates' :  left of '[' is not of type array, matrix, or vecto

image

I just slightly modified the original index.js in the mobilenet example and the script look like this:

import * as tf from '@tensorflow/tfjs';

const MODEL_URL = 'path_to_tensorflowjs_model.pb';
const WEIGHTS_URL = 'path_to_weights_manifest.json';

let gan;
const ganDemo = async () => {
  status('Loading model...');

  gan = await tf.loadFrozenModel(MODEL_URL, WEIGHTS_URL);
  gan.predict(tf.zeros([1, 3, 450, 300])).dispose(); # error here

  ...

I had made sure the model was loaded successfully, and the shape of the input is correct (I intentionally tried other shape, and if the shape is not correct, it will throw another error)

Any suggestions is appreciated.

Upvotes: 0

Views: 148

Answers (1)

Ping Yu
Ping Yu

Reputation: 392

What is the version of tfjs npm you are using? Can you try to use the latest version v1.0.0-alpha2 or v0.15.1?

There is a bug fix related to sparseToDense op.

Upvotes: 1

Related Questions