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.

Session fail to run with error: indices = 1

See original GitHub issue

TensorFlow.js version

1.5

Browser version

NA

Describe the problem or feature request

tf.saved_model with embeddings fails on model.predict in tfjs-node.

Code to reproduce the bug / link to feature request

const model = await tf.node.loadSavedModel(savedModelPath);
const input = {
        "f1": tf.tensor(['dfsdfsdf']),
        "f2": tf.tensor([1719.0]),
        "f3": tf.tensor(['ouipoio']),
        "f4": tf.tensor(['trterte']),
        "f5": tf.tensor(['sdsddsf']),
        "f6": tf.tensor(['tretert']),
        "f7": tf.tensor(['sdfsdf']),
        "f8": tf.tensor([12.0]),
        "f9": tf.tensor(['defg']),
        "f10": tf.tensor(['abcd'])
}
const output = model.predict(input);

All the features other than f8 and f2 numerical columns have embeddings. My Python code looks very similar to https://www.tensorflow.org/tutorials/structured_data/feature_columns. All my embedding feature columns have num_oov_buckets=1 if that helps in any way. After training I saved it using model.save("some_path", save_format='tf').

And here is the full stack trace,

2020-02-12 01:14:46.522724: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-02-12 01:14:46.562096: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1072cbfc0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-02-12 01:14:46.562129: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
Loading model from <PROJECT_HOME>/saved_model/keras_saved_model
2020-02-12 01:14:46.923646: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: <PROJECT_HOME>/saved_model/keras_saved_model
2020-02-12 01:14:46.943722: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve }
2020-02-12 01:14:47.070512: I tensorflow/cc/saved_model/loader.cc:202] Restoring SavedModel bundle.
2020-02-12 01:14:47.328407: I tensorflow/cc/saved_model/loader.cc:151] Running initialization op on SavedModel bundle at path: <PROJECT_HOME>/saved_model/keras_saved_model
2020-02-12 01:14:47.575025: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: success. Took 651378 microseconds.

(node:99068) UnhandledPromiseRejectionWarning: Error: Session fail to run with error: indices = 1 is not in [0, 1)
	 [[{{node sequential/dense_features/f9/f9_weights/GatherV2}}]]
    at NodeJSKernelBackend.runSavedModel (<PROJECT_HOME>/node_modules/@tensorflow/tfjs-node/dist/nodejs_kernel_backend.js:1556:43)
    at TFSavedModel.predict (<PROJECT_HOME>/node_modules/@tensorflow/tfjs-node/dist/saved_model.js:347:52)
    at predict (<PROJECT_HOME>/MY_FILE.js:28:26)
    at main (<PROJECT_HOME>/MY_FILE.js:47:5)
(node:99068) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:99068) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dsmilkovcommented, Feb 13, 2020
  • tf.tensor(['sdfsdf']) infers shape of [1]
  • tf.tensor(['sdfsdf'], [1, 1], 'string') gives shape of [1,1].

Both are working as intended. If you want to infer shape of [1,1], you have to do tf.tensor([['sdfsdf']])

0reactions
Nithanaroycommented, Feb 13, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

OP_REQUIRES failed at sparse_tensor_dense_matmul_op.cc ...
The code fails when it runs the batch_acc = sess.run(accuracy ... Invalid argument: k (784) from index[4352,1] out of bounds (>=784)
Read more >
Tensorflow Object Detection API `indices[3] = 3 is not in [0, 3 ...
When I use small amount of data (around 1K images), the error happens after around 100 steps of training. The error code structure...
Read more >
"SFDC_31103 [FATAL] QueryMore failed." when running a ...
​A session reading from a Salesforce object fails with the following error: READER_1_1_1> SFDC_31103 [FATAL] QueryMore failed.
Read more >
Failed to launch session with the error code “Your session ...
Solution 1: Please confirm if the VDA Server has reached the settings you specified in above HDX policies. This can be checked: Using...
Read more >
session_start - Manual - PHP
session_start() now returns false and no longer initializes $_SESSION when it failed to start the session. Examples ¶. A basic session example ¶....
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