0

我已经使用 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
------------------------

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

4

1 回答 1

0

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

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

于 2018-05-10T00:28:20.800 回答