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: Unsupported tensor DataType: DT_INT64, try to modify the model in python to convert the datatype

See original GitHub issue

Hello, I’m trying to convert this TFJS GraphModel:

tfconv.loadGraphModel(
      'https://tfhub.dev/tensorflow/tfjs-model/toxicity/1/default/1',
      { fromTFHub: true })

The conversion works without any issues with the command tfjs_graph_converter --output_format tf_saved_model ./ ./saved/ But, when I try to load the saved model

tf.node.loadSavedModel(this.path)];

I get the error

(node:39361) UnhandledPromiseRejectionWarning: Error: Unsupported tensor DataType: DT_INT64, try to modify the model in python to convert the datatype

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
loretoparisicommented, Oct 5, 2020

@patlevin ah right!!

tfjs_graph_converter --output_format tf_saved_model --compat_mode ./ ./saved/
TensorFlow.js Graph Model Converter

Graph model:    ./
Output:         ./saved/
Target format:  tf_saved_model

Converting.... Done.
Conversion took 1.667s

...
2020-10-05 12:28:55.915996: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: /Users/loretoparisi/webservice/toxicity_model/saved
2020-10-05 12:28:55.943074: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve }
2020-10-05 12:28:56.009469: I tensorflow/cc/saved_model/loader.cc:202] Restoring SavedModel bundle.
2020-10-05 12:28:56.010138: I tensorflow/cc/saved_model/loader.cc:212] The specified SavedModel has no variables; no checkpoints were restored. File does not exist: /Users/loretoparisi/webservice/toxicity_model/saved/variables/variables.index
2020-10-05 12:28:56.010284: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: success. Took 94285 microseconds.
loadSavedModel OK

Perfect it works! Thank you! 🥇

1reaction
patlevincommented, Oct 5, 2020

@loretoparisi You need to use the compatibility flag:

tfjs_graph_converter --output_format --compat_mode tf_saved_model ./ ./saved/

The compatibility-mode is optional - the default behaviour is to keep all types as-is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when trying to fit the model Failed to convert a NumPy ...
Error when trying to fit the model Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray) ; type(feature_train)) ...
Read more >
tf.data: Build TensorFlow input pipelines
The tf.data API enables you to build complex input pipelines from simple, reusable pieces. For example, the pipeline for an image model might...
Read more >
torch.Tensor — PyTorch 1.13 documentation
Tensor is a multi-dimensional matrix containing elements of a single data type. Data types. Torch defines 10 tensor types with CPU and GPU...
Read more >
ValueError: Failed to convert a NumPy array to a Tensor ...
As X_train and y_train are pandas.core.series.Series they can't be parsed. Try converting them to list as below: X=train[features].to_list() ...
Read more >
Convert numpy array to tensor
The value can be a numpy array, python list and python scalars, for the following the function will return a tensor. Table of...
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