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.

ValueError: Unsupported Ops in the model before optimization StatefulPartitionedCall

See original GitHub issue

TensorFlow.js version: 2.0.1.post1

Browser version: Chrome Version 83.0.4103.106 (Official Build) (64-bit)

Describe the problem or feature request

I am trying to convert a TensorFlow saved_model to TensorFlowJS type with a “quantize” flag. The model uses Huggingface’s Distillbert as a layer as follows.

config = DistilBertConfig.from_pretrained( 'distilbert-base-uncased')
config.output_hidden_states = False
distillbert_main = TFDistilBertMainLayer(config = config)

input_word_ids = tf.keras.layers.Input(shape=(8,), dtype = tf.int32, name = "input_word_ids"),
x = distillbert_main(input_word_ids)[0]
x = tf.keras.layers.Lambda(lambda seq: seq[:, 0, :])(x)
x = tf.keras.layers.BatchNormalization()(x)
x = tf.keras.layers.Dropout(0.2)(x)
out = tf.keras.layers.Dense(2)(x)

model = tf.keras.Model(inputs=input_word_ids, outputs=out)
for layer in model.layers[:3]:
    layer.trainable = False
model.summary() # Works fine
model.get_config() # Works fine
tf.saved_model.save(model, './models/model') # works fine
tfjs.converters.convert_tf_saved_model('./models/model', './models/tfjs') # does not work

I know tfjs currently supports Image-based models, and Models with control flow ops (e.g., RNNs) are also supported. It would be great to see if tfjs team could add the features that convert the attention-based models like the model above.

Code to reproduce the bug / link to feature request

tensorflowjs_converter --quantize_float16 --input_format=tf_saved_model /Users/sabber/Desktop/node_test/model /Users/sabber/Desktop/node_test/model/quantized

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
AIshutincommented, Jul 19, 2020

Hi! I have the same error. @msahamed, did you manage to solve it or avoid somehow? (I need to run DistilBERT in a browser too)

0reactions
msahamedcommented, Aug 4, 2020

@msahamed @Alshutin This fixed by this PR #3685 You can wait for next release 2.1.0, we should be releasing this week or earlier next week.

Thank you for helping. It works with release 2.1.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tensorflowjs Conversion Error: "ValueError: Unsupported Ops"
The short answer is yes, you will need to change them. TensorflowJS will change the ops for optimisation purposes, but not all the...
Read more >
Why Unsupported Ops in the model before optimization ...
ValueError : Unsupported Ops in the model before optimization IteratorV2, IteratorGetNext. I tested TensorFlow 1.11 and 1.12, I use TFRecordDataset and an ...
Read more >
Export OpenAI GPT-2 model into SavedModel.ipynb - Colaboratory
... line 143, in optimize_graph ', '.join(unsupported)) ValueError: Unsupported Ops in the model before optimization StatefulPartitionedCall ...
Read more >
Converting a TensorFlow Model - OpenVINO™ documentation
If a model contains operations currently unsupported by OpenVINO, ... nodes in the StatefulPartitionedCall/\* subgraph of TensorFlow 2.x SavedModel format.
Read more >
Top 5 tensorflowjs Code Examples - Snyk
tensorflow / tfjs / integration_tests / benchmarks / python / benchmarks.py ... raise ValueError('Unsupported Ops in the model before optimization\n' + ' ...
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