我试图了解如何在 OpenVino 的模型优化器中添加对 TensorFlow 层 FusedBatchNormV3 的支持。我在 Ubuntu 18.03 上运行并使用 Tensorflow 15。
我的目标是在 Neural Computer Stick 2 上使用一些预训练的标准网络进行几次测试,我现在正在使用 ResNet50。我下载的网络如下:
import tensorflow as tf
keras = tf.keras
input_shape = (200,200,3)
model = keras.applications.resnet50.ResNet50(input_shape=input_shape,
include_top=False,
weights='imagenet')
在我按照这篇文章model
中的描述冻结之后。
我正在使用以下命令运行模型优化器:
sudo python3 mo.py \
--input_model ~<PATH_TO_MODEL>/model.pb \
--output_dir ~<PATH_TO_MODEL> \
--data_type FP16 -b 1
但我收到此错误消息:
[ ERROR ] 1 elements of 64 were clipped to infinity while converting a blob for node [['conv1_bn_1/cond/FusedBatchNormV3_1/ReadVariableOp_1/Output_0/Data__const']] to <class 'numpy.float16'>.
For more information please refer to Model Optimizer FAQ (https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html), question #76.
[ ERROR ] List of operations that cannot be converted to Inference Engine IR:
[ ERROR ] FusedBatchNormV3 (53)
[ ERROR ] conv1_bn_1/cond/FusedBatchNormV3_1
[ ERROR ] conv2_block1_0_bn_1/cond/FusedBatchNormV3_1
[ ERROR ] conv2_block1_1_bn_2/cond/FusedBatchNormV3_1
...
[ ERROR ] conv5_block3_3_bn_1/cond/FusedBatchNormV3_1
[ ERROR ] Part of the nodes was not converted to IR. Stopped.
我发现这个论坛帖子建议将 TensorFlow 降级到版本 13,但这样做之后,我在同一层也遇到了另一个错误:
[ ERROR ] Cannot infer shapes or values for node "conv1_bn_1/cond/FusedBatchNormV3_1".
[ ERROR ] Op type not registered 'FusedBatchNormV3' in binary running on <USER>. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.
我目前的想法是通过使用模型优化器中引入的 Sub-Graph 替换来添加对 FusedBatchNormV3 的支持(在这个官方页面中描述)。我想用FusedBatchNormV3
操作来替换函数ScaleShift
,因为据说这里 FusedBatchNorm
是关联的,但我不知道如何找到这个ScaleShift
对象。有人可以帮帮我吗?