当前位置: 首页 > 知识库问答 >
问题:

我试图做一个量化的mobilenet模型到tensorflow lite模型,但遇到了一个错误

傅翰池
2023-03-14

首先,我从Mobilenet下载了一个量化模型。它包含在Mobilenet_v1_1.0_224中。然后我做了下面的事情

bazel-bin/tensorflow/contrib/lite/toco/toco \
> --input_files=Sample/mobilenet_v1_1.0_224/quantized_graph.pb \
> --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE \
> --output_file=Sample/mobilenet_v1_1.0_224/quantized_graph.tflite --inference_type=QUANTIZED_UINT8 \
> --input_shape=1,224,224,3 \
> --input_array=input \
> --output_array=MobilenetV1/Predictions/Reshape_1 \
> --mean_value=128 \
> --std_value=127

以下是图表的摘要

bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --in_graph=Sample/mobilenet_v1_1.0_224/quantized_graph.pb
Found 1 possible inputs: (name=input, type=float(1), shape=[1,224,224,3]) 
No variables spotted.
Found 1 possible outputs: (name=MobilenetV1/Predictions/Reshape_1, op=Reshape) 
Found 4227041 (4.23M) const parameters, 0 (0) variable parameters, and 0 control_edges
Op types used: 91 Const, 27 Add, 27 Relu6, 15 Conv2D, 13 DepthwiseConv2dNative, 13 Mul, 10 Dequantize, 2 Reshape, 1 Identity, 1 Placeholder, 1 BiasAdd, 1 AvgPool, 1 Softmax, 1 Squeeze
To use with tensorflow/tools/benchmark:benchmark_model try these arguments:
bazel run tensorflow/tools/benchmark:benchmark_model -- --graph=Sample/mobilenet_v1_1.0_224/quantized_graph.pb --show_flops --input_layer=input --input_layer_type=float --input_layer_shape=1,224,224,3 --output_layer=MobilenetV1/Predictions/Reshape_1

因此,通过进行转换,我遇到了以下错误

2018-03-01 23:12:03.353786:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.354513:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.355177:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.35556:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.355921:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.356281:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.356632:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.357540:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.358776:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:反量化2018-03-01 23:12:03.360448:I tensorflow/contrib/lite/toco/import_tensorflow。cc:1172]转换不支持的操作:去量化2018-03-01 23:12:03.366319:I tensorflow/contrib/lite/toco/graph_转换/graph_转换。cc:39]删除未使用的ops之前:140个运算符,232个数组(0量化)2018-03-01 23:12:03.371405:I tensorflow/contrib/lite/toco/graph_变换/graph_变换。cc:39]一般图形转换之前:140个运算符,232个数组(0量化)2018-03-01 23:12:03.374916:I tensorflow/contrib/lite/toco/graph_转换/graph_转换。cc:39]一般图变换通过1:63运算符后,152个数组(1个量化)2018-03-01 23:12:03.376325:I tensorflow/contrib/lite/toco/graph_变换/graph_变换。cc:39]在预量化图形转换之前:63个操作符,152个数组(1个量化)2018-03-01 23:12:03.377492:F tensorflow/contrib/lite/toco/tooling_util。cc:1272]Array MobilenetV1/MobilenetV1/Conv2d_0/Relu6缺少量化所需的最小/最大数据,该数组是产生输出数组MobilenetV1/MobilenetV1/Conv2d_1_depthwise/Relu6的DepthwiseConv运算符的输入。以非量化输出格式为目标,或者更改输入图形以包含最小/最大信息,或者传递--default\u ranges\u min=和--default\u ranges\u max=如果您不关心结果的准确性。

谢谢你的帮助

共有1个答案

李博达
2023-03-14

我想你可能指的是一个旧的TensorFlow量化mobilenet模型。

我们已经更新了这里可用的量化mobilenet模型。深度倍增器1.0和图像大小224的具体链接如下。

这些tar文件还附带已经转换的tfliteflatbuffer模型。

我希望这有帮助!

 类似资料:
  • 我要离开一个网站(https://realpython.com/how-to-make-a-discord-bot-python/#how-to-make-a-discord-bot-in-python)和我下面的步骤,但我一直得到一个错误msg Traceback(最近一次调用最后一次): File"C:\用户\Bryce.Persello346\Desktop\bot.py",第15行,cli

  • 我是Tensorflow的初学者,请原谅我这个简单的问题,但我在哪里都找不到这个答案。我正致力于将mobilenet分段模型(http://download.tensorflow.org/models/deeplabv3_mnv2_pascal_trainval_2018_01_29.tar.gz)转换为Tensorflow-lite,用于移动推理,已经用了一个多星期了,但没有成功。我无法正确定义

  • 在react native中遇到问题“无法安装应用程序。请确保您拥有Android开发环境”

  • 正如您在TensorFlow中实现的量化MobileNet模型的屏幕截图中看到的那样,仍然有一些浮动操作。量化是通过graph_transform工具在TensorFlow中完成的。 图像中的红色椭圆在右侧大小文本框中有其描述。“depthwise”是一个“depthwiseConv2Native”操作,需要“DT_FLOAT”输入。 尽管较低的Relu6执行8位量化操作,但结果必须经过“(Rel

  • 我正在写一个库在Java,我需要转换(地图)一个模型到另一个,反之亦然。我所做的是实现了一个包含两个泛型类型的抽象转换器类,包含convertTo和convertFrom方法,并从它扩展了我的转换器。 但是对于特定的实现,我可能还需要其他对象来进行转换,我不知道什么是实现这些东西的最佳实践。我想过适配器和门面,但他们似乎不符合我的要求。有没有一个设计模式我可以用来做这个?提前谢谢你。

  • 我试图在webGL中构建我的游戏,但我得到了这个错误 找不到文件“C:\users----\OneDrive\Documents\Endless\Runner\Temp\StagingArea\Data\Native\Build.bc” 我对unity和stackoverflow很陌生,所以不要对我太苛刻。