Intel® Distribution of OpenVINO™ Toolkit
Community support and discussions about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all things computer vision-related on Intel® platforms.

GRU layer - failed conversion with TF 2.9.1

bencegg
Beginner
404 Views

Hello!

System information (version)
  • OpenVINO => 2022.2
  • Operating System / Platform => Ubuntu 20.04.5 LTS
  • Compiler =>
  • Problem classification: Model Conversion
  • Framework: TensorFlow

There is an issue, when converting a simple TF network with GRU layer which was trained on TensorFlow 2.8 and saved into SavedModel format, there is no problem. I can convert my model easily without any error, with this code:

mo --saved_model_dir /work/user/saved_model/my_model/ --input_shape [?,28,28] --output_dir /work/user/saved_model/vino

But when I change Tensorflow version to 2.9.1, and I train a TF network with GRU layer and save into SavedModel format, I get an error like this:

[ ERROR ]  Cannot infer shapes or values for node "StatefulPartitionedCall/sequential/gru/PartitionedCall/TensorArrayV2_1".
[ ERROR ]  Graph execution error:

Tensorflow type 21 not convertible to numpy dtype.
[ ERROR ]  
[ ERROR ]  It can happen due to bug in custom shape infer function <function tf_native_tf_node_infer at 0x7f6bf1b1c700>.
[ ERROR ]  Or because the node inputs have incorrect values/shapes.
[ ERROR ]  Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
[ ERROR ]  Run Model Optimizer with --log_level=DEBUG for more information.
[ ERROR ]  Exception occurred during running replacer "REPLACEMENT_ID" (<class 'openvino.tools.mo.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "StatefulPartitionedCall/sequential/gru/PartitionedCall/TensorArrayV2_1" node. 
 For more information please refer to Model Optimizer FAQ, question #38. (https://docs.openvino.ai/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=38#question-38) 

 A short code, to reproduce this problem:

import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers

model = keras.Sequential()
model.add(layers.GRU(64, input_shape=(28, 28)))
model.add(layers.BatchNormalization())
model.add(layers.Dense(10))
print(model.summary())

mnist = keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train/255.0, x_test/255.0
x_validate, y_validate = x_test[:-10], y_test[:-10]
x_test, y_test = x_test[-10:], y_test[-10:]

model.compile(
    loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
    optimizer="sgd",
    metrics=["accuracy"],
)
model.fit(
    x_train, y_train, validation_data=(x_validate, y_validate), batch_size=64, epochs=5
)
model.save('saved_model/my_model')

Then converting with this code:

mo --saved_model_dir /work/user/saved_model/my_model/ --input_shape [?,28,28] --output_dir /work/user/saved_model/vino

It works well with TF 2.8, but after the change TF to 2.9.1, I get an error, like above.

 

0 Kudos
4 Replies
Zulkifli_Intel
Moderator
374 Views

Hello Bencegg,

Thank you for reaching out to us.

 

I replicated your issue and received the same result as yours.

error.PNG

 

I will investigate this issue and will get back to you soon.

 

Sincerely,

Zulkifli 

 

Zulkifli_Intel
Moderator
108 Views

Hello Bencegg,

 

Our developers are working to rectify this issue, please monitor this GitHub thread for updates.

Since this is a duplicate case from GitHub, can we close this thread and move our focus there?

 

Sincerely,

Zulkifli 


bencegg
Beginner
88 Views

Hello Zulkifli,

 

Yes, thank you!

 

Sincerely,

Bence 

Zulkifli_Intel
Moderator
80 Views

Hello Bencegg,


This thread will no longer be monitored since we focus this issue on this GitHub thread. If you need any additional information from Intel, please submit a new question.


Sincerely,

Zulkifli


Reply