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

OpenVINO model conversion error, Please contact Model Optimizer developers and forward the following information

Lee__Robin
Beginner
843 Views

Hello,

I'm using OpenVINO™ toolkit 2019 R2 in my Ubuntu 16.04 in a virtualbox and the Model Optimizer to convert a tensorflow model to Intermediate Representation via the following commande:

             sudo python3 mo.py --input_meta_graph /home/pi/Work/Tensorflow2OpenVino/TF_Model/tf_model.meta

And i got the following error message as

-------------------------

Model Optimizer version:     2019.2.0-436-gf5827d4
[ ERROR ]  Shape [ -1  25 513] is not fully defined for output 0 of "lstm_1_input". Use --input_shape with positive integers to override model input shapes.
[ ERROR ]  Cannot infer shapes or values for node "lstm_1_input".
[ ERROR ]  Not all output shapes were inferred or fully defined for node "lstm_1_input".
 For more information please refer to Model Optimizer FAQ (https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html), question #40.
[ ERROR ]  
[ ERROR ]  It can happen due to bug in custom shape infer function <function Parameter.__init__.<locals>.<lambda> at 0x7f53afc99730>.
[ 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 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "lstm_1_input" node.
 For more information please refer to Model Optimizer FAQ (https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html), question #38.

-------------------------------------

After reading the FAQ, i updated the command of the model conversion as

           sudo python3 mo.py --input_meta_graph /home/pi/Work/Tensorflow2OpenVino/TF_Model/tf_model.meta --input_shape [1,25,513]

And then i got the following error messages :

---------------------------------------------------------

Model Optimizer version:     2019.2.0-436-gf5827d4
[ ERROR ]  -------------------------------------------------
[ ERROR ]  ----------------- INTERNAL ERROR ----------------
[ ERROR ]  Unexpected exception happened.
[ ERROR ]  Please contact Model Optimizer developers and forward the following information:
[ ERROR ]  Exception occurred during running replacer "REPLACEMENT_ID (<class 'extensions.middle.EltwiseChecker.EltwiseChecker'>)": index -1 is out of bounds for axis 0 with size 0
[ ERROR ]  Traceback (most recent call last):
  File "/opt/intel/openvino_2019.2.275/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 273, in apply_replacements
    for_graph_and_each_sub_graph_recursively(graph, replacer.find_and_replace_pattern)
  File "/opt/intel/openvino_2019.2.275/deployment_tools/model_optimizer/mo/middle/pattern_match.py", line 58, in for_graph_and_each_sub_graph_recursively
    func(graph)
  File "/opt/intel/openvino_2019.2.275/deployment_tools/model_optimizer/extensions/middle/EltwiseChecker.py", line 73, in find_and_replace_pattern
    np.put(possible_shape, feature_dim, tensor_shape.item(feature_dim))
IndexError: index -1 is out of bounds for axis 0 with size 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/intel/openvino_2019.2.275/deployment_tools/model_optimizer/mo/main.py", line 302, in main
    return driver(argv)
  File "/opt/intel/openvino_2019.2.275/deployment_tools/model_optimizer/mo/main.py", line 251, in driver
    is_binary=not argv.input_model_is_text)
  File "/opt/intel/openvino_2019.2.275/deployment_tools/model_optimizer/mo/pipeline/tf.py", line 134, in tf2nx
    class_registration.apply_replacements(graph, class_registration.ClassType.MIDDLE_REPLACER)
  File "/opt/intel/openvino_2019.2.275/deployment_tools/model_optimizer/mo/utils/class_registration.py", line 299, in apply_replacements
    )) from err
Exception: Exception occurred during running replacer "REPLACEMENT_ID (<class 'extensions.middle.EltwiseChecker.EltwiseChecker'>)": index -1 is out of bounds for axis 0 with size 0

[ ERROR ]  ---------------- END OF BUG REPORT --------------
[ ERROR ]  -------------------------------------------------

---------------------------------------------------

 

can i have some help regarding this problem please? Thank you very much.

 

0 Kudos
4 Replies
Shubha_R_Intel
Employee
843 Views

Dear Lee, Robin,

The below error should go away if you pass in --batch 1 or --input_shape [1,25,513]. Model Optimizer requires all values in the shape to be positive numbers. The first position is "batch size".

[ ERROR ]  Shape [ -1  25 513] is not fully defined for output 0 of "lstm_1_input". Use --input_shape with positive integers to override model input shapes.

Hope it helps,

Thanks,

Shubha

0 Kudos
Lee__Robin
Beginner
843 Views

Shubha R. (Intel) wrote:

Dear Lee, Robin,

The below error should go away if you pass in --batch 1 or --input_shape [1,25,513]. Model Optimizer requires all values in the shape to be positive numbers. The first position is "batch size".

[ ERROR ]  Shape [ -1  25 513] is not fully defined for output 0 of "lstm_1_input". Use --input_shape with positive integers to override model input shapes.

Hope it helps,

Thanks,

Shubha

Hi Shubha,

Thanks for the answer, i had tried your suggestion and got the second error message at the bottom of my initial post, do you have any idea why? 

 

 

 

0 Kudos
Shubha_R_Intel
Employee
843 Views

Dear Lee, Robin,

If you are talking about this error:

   np.put(possible_shape, feature_dim, tensor_shape.item(feature_dim))
IndexError: index -1 is out of bounds for axis 0 with size 0

The above exception was the direct cause of the following exception:

You still have a negative number problem. Perhaps you can convert your tensorflow frozen pb into text and snoop around at the layer Model Optimizer complains about just before that error. If there's a -1 somewhere in the dimensions, Model Optimizer will scream (just like the above error). But converting to *.pbtxt should certainly give a you a clue about the problematic layer with the negative -1 dimension. 

Shubha

 

0 Kudos
Shubha_R_Intel
Employee
843 Views

PS, here's my favorite Python code for converting a frozen pb to text:

import tensorflow as tf
from tensorflow.python.lib.io import file_io
from tensorflow.core.protobuf import saved_model_pb2

def load_graph(frozen_graph_filename):
    # We load the protobuf file from the disk and parse it to retrieve the
    # unserialized graph_def
    with tf.io.gfile.GFile(frozen_graph_filename, "rb") as f:
        graph_def = tf.compat.v1.GraphDef()
        graph_def.ParseFromString(f.read())

    # Then, we import the graph_def into a new Graph and return it
    with tf.Graph().as_default() as graph:
        # The name var will prefix every op/nodes in your graph
        # Since we load everything in a new graph, this is not needed
        tf.import_graph_def(graph_def, name="prefix")
    return graph


if __name__ == '__main__':
    mygraph = load_graph("C:\\Users\\mickeymouse\\Downloads\\element_wise_mul_float\\element_wise_mul_float.pb")
    tf.io.write_graph(mygraph, "C:\\Users\\mickeymouse\\Downloads\\element_wise_mul_float", "saved_model.txt")

 

0 Kudos
Reply