MatMul 无法推断形状,因为输入尺寸不兼容
MatMul wasn't able to infer shape because input dimensions are not compatible
我正在 运行 OpenVINO 优化 frozon .pb 模型文件。 运行 优化时,显示以下错误消息:
E0806 16:58:26.145075 140020238079808 matmul.py:52] MatMul wasn't able to infer shape because input dimensions are not compatible
E0806 16:58:26.146022 140020238079808 infer.py:152] Shape is not defined for output 0 of "lstm_27/while/MatMul_3".
E0806 16:58:26.146118 140020238079808 infer.py:180] Cannot infer shapes or values for node "lstm_27/while/MatMul_3".
E0806 16:58:26.146183 140020238079808 infer.py:181] Not all output shapes were inferred or fully defined for node "lstm_27/while/MatMul_3".
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.
E0806 16:58:26.146232 140020238079808 infer.py:182]
E0806 16:58:26.146281 140020238079808 infer.py:183] It can happen due to bug in custom shape infer function <function tf_matmul_infer at 0x7f586c514e18>.
E0806 16:58:26.146322 140020238079808 infer.py:184] Or because the node inputs have incorrect values/shapes.
E0806 16:58:26.146360 140020238079808 infer.py:185] Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
model.summary()
的输出
Model: "sequential_11"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
lstm_27 (LSTM) (None, 10, 50) 10600
_________________________________________________________________
lstm_28 (LSTM) (None, 10, 40) 14560
_________________________________________________________________
lstm_29 (LSTM) (None, 30) 8520
_________________________________________________________________
dense_7 (Dense) (None, 1) 31
=================================================================
Total params: 33,711
Trainable params: 33,711
Non-trainable params: 0
我运行优化如下
input_shape = [0, 10, 50]
input_shape_str = str(input_shape).replace(' ','')
input_shape_str
!python3 {mo_tf_path} --input_model {pb_file} --output_dir {output_dir} --input_shape {input_shape_str} --data_type FP32
这里有什么问题?
mo_tf 需要精确的输入形状才能工作,即 input_shape = [1, 10, 50]。使用 -1、0 或跳过第一个维度将引发错误。
我正在 运行 OpenVINO 优化 frozon .pb 模型文件。 运行 优化时,显示以下错误消息:
E0806 16:58:26.145075 140020238079808 matmul.py:52] MatMul wasn't able to infer shape because input dimensions are not compatible
E0806 16:58:26.146022 140020238079808 infer.py:152] Shape is not defined for output 0 of "lstm_27/while/MatMul_3".
E0806 16:58:26.146118 140020238079808 infer.py:180] Cannot infer shapes or values for node "lstm_27/while/MatMul_3".
E0806 16:58:26.146183 140020238079808 infer.py:181] Not all output shapes were inferred or fully defined for node "lstm_27/while/MatMul_3".
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.
E0806 16:58:26.146232 140020238079808 infer.py:182]
E0806 16:58:26.146281 140020238079808 infer.py:183] It can happen due to bug in custom shape infer function <function tf_matmul_infer at 0x7f586c514e18>.
E0806 16:58:26.146322 140020238079808 infer.py:184] Or because the node inputs have incorrect values/shapes.
E0806 16:58:26.146360 140020238079808 infer.py:185] Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
model.summary()
的输出Model: "sequential_11"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
lstm_27 (LSTM) (None, 10, 50) 10600
_________________________________________________________________
lstm_28 (LSTM) (None, 10, 40) 14560
_________________________________________________________________
lstm_29 (LSTM) (None, 30) 8520
_________________________________________________________________
dense_7 (Dense) (None, 1) 31
=================================================================
Total params: 33,711
Trainable params: 33,711
Non-trainable params: 0
我运行优化如下
input_shape = [0, 10, 50]
input_shape_str = str(input_shape).replace(' ','')
input_shape_str
!python3 {mo_tf_path} --input_model {pb_file} --output_dir {output_dir} --input_shape {input_shape_str} --data_type FP32
这里有什么问题?
mo_tf 需要精确的输入形状才能工作,即 input_shape = [1, 10, 50]。使用 -1、0 或跳过第一个维度将引发错误。