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.

Problem with using model_optimizer to convert tensorflow model

Ant__Michael
Beginner
479 Views

[ 2019-08-15 14:06:37,937 ] [ DEBUG ] [ class_registration:267 ]  Run replacer <class 'extensions.middle.EltwiseInputReshape.Eltwise1DInputReshape'>
[ 2019-08-15 14:06:37,951 ] [ DEBUG ] [ op:207 ]  Start running infer function for individual op node with attributes: {'precision': 'FP32', 'kind': 'op', 'type': 'Reshape', 'op': 'Reshape', 'reinterp_shape': True, 'in_ports_count': 2, 'out_ports_count': 1, 'infer': <function Reshape.infer at 0x7f1379559378>, 'dim': array([1, 1, 1, 1]), 'name': 'batch_normalization/batchnorm/mul/Output_0/Data_/Broadcast', 'dim_attrs': ['batch_dims', 'channel_dims', 'spatial_dims', 'axis'], 'shape_attrs': ['window', 'output_shape', 'stride', 'pad', 'shape'], 'IE': [('layer', [('id', <function Op.substitute_ie_attrs.<locals>.<lambda> at 0x7f1376330400>), 'name', 'precision', 'type'], [('data', [], []), '@ports', '@consts'])], '_in_ports': {0: {}, 1: {}}, '_out_ports': {0: {}}}
[ 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.EltwiseInputReshape.Eltwise1DInputReshape'>)": The Reshape operation batch_normalization/batchnorm/mul/Output_0/Data_/Broadcast must have 2 inputs
[ ERROR ]  Traceback (most recent call last):
  File "/opt/intel/openvino_2019.2.242/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.242/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.242/deployment_tools/model_optimizer/extensions/middle/EltwiseInputReshape.py", line 67, in find_and_replace_pattern
    reshape_data_node = reshape_data_op.create_node_with_data([node])
  File "/opt/intel/openvino_2019.2.242/deployment_tools/model_optimizer/mo/ops/op.py", line 208, in create_node_with_data
    new_op_node.infer(new_op_node)
  File "/opt/intel/openvino_2019.2.242/deployment_tools/model_optimizer/mo/ops/reshape.py", line 47, in infer
    lambda node: np.reshape(node.in_node(0).value, node.out_node().shape)
  File "/opt/intel/openvino_2019.2.242/deployment_tools/model_optimizer/mo/front/common/partial_infer/elemental.py", line 19, in single_output_infer
    node.out_node(0).shape = shape_infer(node)
  File "/opt/intel/openvino_2019.2.242/deployment_tools/model_optimizer/mo/front/common/partial_infer/reshape.py", line 30, in tf_reshape_shape_infer
    assert len(node.in_nodes()) == 2, 'The Reshape operation {} must have 2 inputs'.format(node.name)
AssertionError: The Reshape operation batch_normalization/batchnorm/mul/Output_0/Data_/Broadcast must have 2 inputs

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

Traceback (most recent call last):
  File "/opt/intel/openvino_2019.2.242/deployment_tools/model_optimizer/mo/main.py", line 302, in main
    return driver(argv)
  File "/opt/intel/openvino_2019.2.242/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.242/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.242/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.EltwiseInputReshape.Eltwise1DInputReshape'>)": The Reshape operation batch_normalization/batchnorm/mul/Output_0/Data_/Broadcast must have 2 inputs

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

0 Kudos
5 Replies
Shubha_R_Intel
Employee
479 Views

Dear Ant, Michael,

First of all, thank you for installing OpenVino 2019R2 ! Can you kindly tell me more about your tensorflow model ? What kind is it ? Where did you get it ? Is it pre-trained or custom-trained ? Here is the Model Optimizer Supported and Validated Tensorflow List . I hope you pulled your model from one of those.

Anyway. Let me know more. I am glad to help you !

Sincerely,

Shubha

0 Kudos
Ant__Michael
Beginner
479 Views

Dear Shubha,

The model I use isn't a public model, it's a custom-trained, but I can provide information about it by your request (the overall visualization of the graph you can find in graph.png: https://drive.google.com/file/d/1ZOps6ilzabGiPzp3K4_O_OOjeyg0yjPY/view). ;
It seems that all layer types are supported by model optimizer, so you can find more information about model layers types and model topology from the full model optimizer's debug log in attach. To simplify context, I set the output node during conversion not to the last one from the model. (you can find it in log.txt)

Sincerely,
Michael.

0 Kudos
Shubha_R_Intel
Employee
479 Views

Dear Ant, Michael,

I had a chance to look at your log. The Exception is this:

Exception: Exception occurred during running replacer "REPLACEMENT_ID (<class 'extensions.middle.EltwiseInputReshape.Eltwise1DInputReshape'>)": The Reshape operation batch_normalization/batchnorm/mul/Output_0/Data_/Broadcast must have 2 inputs

Please have a look at the IR Catalog for Reshape Operation . As you can see, it expects "multi-dimensional input", so your model must only have 1 or fewer inputs at this layer. Looking at your tensorboard image though I'm not seeing batch_normalization/batchnorm/mul/Output_0/Data_/Broadcast .  

If you are sure this model works and does inference in Tensorflow, then it could be a Model Optimizer bug (I see that you are using GRU in this model, and GRU is definitely supported in OpenVino).  If you feel uncomfortable with providing your model publicly let me know and I can PM you so that you can send it as a *.zip file privately.

I hope it's clear. Let me know if not,

Thanks,

Shubha

0 Kudos
Ant__Michael
Beginner
479 Views

Dear Shubha,

Thanks for your attention to the problem. Inference in tensorflow works good for the model, so I suppose it would good approach to send you this model in PM. Could you describe please, how can I contact with you in PM?

Sincerely,
Michael

0 Kudos
Shubha_R_Intel
Employee
479 Views

Dear Ant, Michael,

I have sent you a PM which will enable you to directly PM me your *.zip file.

Thanks !

Shubha

0 Kudos
Reply