使用optimize_for_inference和graph_transform工具后,初始V3重新训练模型的错误预测

时间:2018-05-08 23:23:17

标签: opencv tensorflow pre-trained-model

我使用poors的tensorflow教程生成了模型。我有二元和三类模型,表现出相同的行为。

forzen图表按预期执行,但是当我将其转换为与opencv dnn模块一起使用时,预测很快就会消失,通常偏向于一个类而不是其他类。

我使用了这里描述的变换: http://answers.opencv.org/question/175699/readnetfromtensorflow-fails-on-retrained-nn/

在这里 https://www.tensorflow.org/mobile/prepare_models

以下是每次转换后的汇总图的输出。万一你看到一些不寻常的东西:

**original** 
--------
No inputs spotted.
No variables spotted.
Found 1 possible outputs: (name=final_result, op=Softmax) 
Found 21826166 (21.83M) const parameters, 0 (0) variable parameters, and 99 control_edges
Op types used: 489 Const, 101 Identity, 99 CheckNumerics, 94 Relu, 94 BatchNormWithGlobalNormalization, 94 Conv2D, 11 Concat, 9 AvgPool, 5 MaxPool, 1 DecodeJpeg, 1 ExpandDims, 1 Cast, 1 MatMul, 1 Mul, 1 PlaceholderWithDefault, 1 Add, 1 Reshape, 1 ResizeBilinear, 1 Softmax, 1 Sub
-----------------------

**After optimize_for_inference**
----------------------------
Found 1 possible inputs: (name=DecodeJpeg/contents, type=float(1), shape=None) 
No variables spotted.
Found 1 possible outputs: (name=final_result, op=Softmax) 
Found 21774517 (21.77M) const parameters, 0 (0) variable parameters, and 0 control_edges
Op types used: 206 Const, 94 BiasAdd, 94 Conv2D, 94 Relu, 11 Concat, 9 AvgPool, 5 MaxPool, 1 Sub, 1 Add, 1 Softmax, 1 ResizeBilinear, 1 Reshape, 1 PlaceholderWithDefault, 1 Placeholder, 1 Mul, 1 MatMul, 1 ExpandDims, 1 DecodeJpeg, 1 Cast
-----------------------------
**transform_graph with strip_unused**

Found 1 possible inputs: (name=Mul, type=float(1), shape=[1,299,299,3]) 
No variables spotted.
Found 1 possible outputs: (name=final_result, op=Softmax) 
Found 21826160 (21.83M) const parameters, 0 (0) variable parameters, and 99 control_edges Op types used: 484 Const, 101 Identity, 99 CheckNumerics, 94 BatchNormWithGlobalNormalization, 94 Conv2D, 94 Relu, 11 Concat, 9 AvgPool, 5 MaxPool, 1 Add, 1 MatMul, 1 Placeholder, 1 PlaceholderWithDefault, 1 Reshape, 1 Softmax
------------------------

我想知道原因是什么以及如何在部署图表时保持推理性能。

1 个答案:

答案 0 :(得分:0)

我认为下面描述的问题是罪魁祸首,但我不确定。

此链接很好地描述了问题 - https://r2rt.com/implementing-batch-normalization-in-tensorflow.html

相关问题